Maintainer | dave@chalmers.se |
---|---|
Safe Haskell | Safe-Inferred |
Parsing
Description
Used in the course Functional Programming GU/Chalmers
- data Parser a
- parse :: Parser a -> String -> Maybe (a, String)
- readsP :: Read a => Parser a
- failure :: Parser a
- sat :: (Char -> Bool) -> Parser Char
- item :: Parser Char
- char :: Char -> Parser Char
- digit :: Parser Char
- (+++) :: Parser a -> Parser a -> Parser a
- (<:>) :: Parser a -> Parser [a] -> Parser [a]
- (>->) :: Parser a -> Parser b -> Parser b
- (<-<) :: Parser b -> Parser a -> Parser b
- oneOrMore :: Parser a -> Parser [a]
- zeroOrMore :: Parser a -> Parser [a]
- chain :: Parser a -> Parser b -> Parser [a]
Documentation
data Parser a
The abstract data type representing a Parser
parse :: Parser a -> String -> Maybe (a, String)
Runs the parser on the given string to return maybe a thing and a string
A parser for anything in the Read class satisfying
parse readsP s == listToMaybe (reads s)
(+++) :: Parser a -> Parser a -> Parser a infixr 5
Try the first parser and if it fails try the second
(<:>) :: Parser a -> Parser [a] -> Parser [a]
Parse a thing, then parse a list of things, and return the first thing followed by the list of things
(>->) :: Parser a -> Parser b -> Parser b
Parse with first, ignore the result and parse with the second. Equivalent to (>>)
(<-<) :: Parser b -> Parser a -> Parser b
Parse with first, then the second, returning the result of the first
zeroOrMore :: Parser a -> Parser [a]
Parse zero or more things