File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -34,13 +34,10 @@ 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 = 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" ) }
37
+ satisfy f = try do
38
+ c <- char
39
+ if f c then return c
40
+ else fail " Character did not satisfied predicate"
44
41
45
42
whiteSpace :: forall m . (Monad m ) => ParserT String m String
46
43
whiteSpace = do
You can’t perform that action at this time.
0 commit comments