diff options
Diffstat (limited to 'Pipes/Text/Parse.hs')
-rw-r--r-- | Pipes/Text/Parse.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Pipes/Text/Parse.hs b/Pipes/Text/Parse.hs index ed0afa1..9cabaa6 100644 --- a/Pipes/Text/Parse.hs +++ b/Pipes/Text/Parse.hs | |||
@@ -44,16 +44,16 @@ nextChar = go | |||
44 | {-| Draw one 'Char' from the underlying 'Producer', returning 'Left' if the | 44 | {-| Draw one 'Char' from the underlying 'Producer', returning 'Left' if the |
45 | 'Producer' is empty | 45 | 'Producer' is empty |
46 | -} | 46 | -} |
47 | drawChar :: (Monad m) => StateT (Producer Text m r) m (Either r Char) | 47 | drawChar :: (Monad m) => StateT (Producer Text m r) m (Maybe Char) |
48 | drawChar = do | 48 | drawChar = do |
49 | x <- PP.draw | 49 | x <- PP.draw |
50 | case x of | 50 | case x of |
51 | Left r -> return (Left r) | 51 | Nothing -> return Nothing |
52 | Right txt -> case (T.uncons txt) of | 52 | Just txt -> case (T.uncons txt) of |
53 | Nothing -> drawChar | 53 | Nothing -> drawChar |
54 | Just (c, txt') -> do | 54 | Just (c, txt') -> do |
55 | PP.unDraw txt' | 55 | PP.unDraw txt' |
56 | return (Right c) | 56 | return (Just c) |
57 | {-# INLINABLE drawChar #-} | 57 | {-# INLINABLE drawChar #-} |
58 | 58 | ||
59 | -- | Push back a 'Char' onto the underlying 'Producer' | 59 | -- | Push back a 'Char' onto the underlying 'Producer' |
@@ -71,12 +71,12 @@ unDrawChar c = modify (yield (T.singleton c) >>) | |||
71 | > Right c -> unDrawChar c | 71 | > Right c -> unDrawChar c |
72 | > return x | 72 | > return x |
73 | -} | 73 | -} |
74 | peekChar :: (Monad m) => StateT (Producer Text m r) m (Either r Char) | 74 | peekChar :: (Monad m) => StateT (Producer Text m r) m (Maybe Char) |
75 | peekChar = do | 75 | peekChar = do |
76 | x <- drawChar | 76 | x <- drawChar |
77 | case x of | 77 | case x of |
78 | Left _ -> return () | 78 | Nothing -> return () |
79 | Right c -> unDrawChar c | 79 | Just c -> unDrawChar c |
80 | return x | 80 | return x |
81 | {-# INLINABLE peekChar #-} | 81 | {-# INLINABLE peekChar #-} |
82 | 82 | ||
@@ -91,8 +91,8 @@ isEndOfChars :: (Monad m) => StateT (Producer Text m r) m Bool | |||
91 | isEndOfChars = do | 91 | isEndOfChars = do |
92 | x <- peekChar | 92 | x <- peekChar |
93 | return (case x of | 93 | return (case x of |
94 | Left _ -> True | 94 | Nothing -> True |
95 | Right _ -> False ) | 95 | Just _-> False ) |
96 | {-# INLINABLE isEndOfChars #-} | 96 | {-# INLINABLE isEndOfChars #-} |
97 | 97 | ||
98 | {-| @(take n)@ only allows @n@ characters to pass | 98 | {-| @(take n)@ only allows @n@ characters to pass |