Created
July 12, 2013 23:54
-
-
Save ericmoritz/5988704 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| simpleParse :: ParseState -> (a, ParseState) | |
| simpleParse = undefined | |
| betterParse :: ParseState -> Either String (a, ParseState) | |
| betterParse = undefined | |
| newtype Parse a = Parse { | |
| runParse :: ParseState -> Either String (a, ParseState) | |
| } | |
| identity :: a -> Parse a | |
| identity a = Parse (\s -> Right (a, s)) | |
| parse :: Parse a -> L.ByteString -> Either String a | |
| parse parser initState | |
| = case runParse parser (ParseState initState 0) of | |
| Left err -> Left err | |
| Right (result, _) -> Right result | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment