mirror of
https://github.com/sdiehl/write-you-a-haskell.git
synced 2024-08-16 07:00:36 +03:00
DRY + nitpicking
This commit is contained in:
parent
1e9b0fba91
commit
d86a804a29
@ -12,7 +12,7 @@ runParser :: Parser a -> String -> a
|
||||
runParser m s =
|
||||
case parse m s of
|
||||
[(res, [])] -> res
|
||||
[(_, rs)] -> error "Parser did not consume entire stream."
|
||||
[(_, _)] -> error "Parser did not consume entire stream."
|
||||
_ -> error "Parser error."
|
||||
|
||||
item :: Parser Char
|
||||
@ -62,7 +62,7 @@ satisfy :: (Char -> Bool) -> Parser Char
|
||||
satisfy p = item `bind` \c ->
|
||||
if p c
|
||||
then unit c
|
||||
else (Parser (\cs -> []))
|
||||
else failure
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Combinators
|
||||
|
Loading…
Reference in New Issue
Block a user