Last active
August 29, 2015 14:01
-
-
Save munro/11e4eecc196a746a7975 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | [33] IntConstant ::= ('+' | '-')? Digit+ | |
-- >>> parse intConstant "fail" "+123" | |
-- Right "+123" | |
-- | |
-- >>> parse intConstant "fail" "0003" | |
-- Right "0003" | |
-- | |
-- >>> parse intConstant "fail" "-321" | |
-- Right "-321" | |
intConstant :: GenParser Char st String | |
intConstant = do | |
chr <- optionMaybe (char '+' <|> char '-') | |
str <- many digit | |
return $ case chr of Just a -> a : str | |
Nothing -> str |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment