Skip to content

Instantly share code, notes, and snippets.

@ericmoritz
Created July 12, 2013 23:54
Show Gist options
  • Select an option

  • Save ericmoritz/5988704 to your computer and use it in GitHub Desktop.

Select an option

Save ericmoritz/5988704 to your computer and use it in GitHub Desktop.
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