File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -34,9 +34,13 @@ char = ParserT $ \s' ->
34
34
_ -> { consumed: true , input: drop 1 s', result: Right (charAt 0 s') }
35
35
36
36
satisfy :: forall m . (Monad m ) => (String -> Boolean ) -> ParserT String m String
37
- satisfy f = do
38
- p <- char
39
- if f p then return p else fail " Character did not satisfy predicate"
37
+ satisfy f = ParserT $ \s' -> case s' of
38
+ " " -> return { consumed: false , input: s', result: Left (strMsg " Unexpected EOF" ) }
39
+ _ ->
40
+ let c = charAt 0 s'
41
+ in return $ if f c
42
+ then { consumed: true , input: drop 1 s', result: Right c }
43
+ else { consumed: false , input: s', result: Left (strMsg " Character did not satisfy predicate" ) }
40
44
41
45
whiteSpace :: forall m . (Monad m ) => ParserT String m String
42
46
whiteSpace = do
You can’t perform that action at this time.
0 commit comments