Maintainerdave@chalmers.se
Safe HaskellSafe-Inferred

Parsing

Description

Used in the course Functional Programming GU/Chalmers

Synopsis

Documentation

data Parser a

The abstract data type representing a Parser

Instances

Monad Parser 
Functor Parser 
Applicative Parser 

parse :: Parser a -> String -> Maybe (a, String)

Runs the parser on the given string to return maybe a thing and a string

readsP :: Read a => Parser a

A parser for anything in the Read class satisfying

parse readsP s == listToMaybe (reads s)

failure :: Parser a

Parser than can never succeed

sat :: (Char -> Bool) -> Parser Char

parse a single character satisfying property p

item :: Parser Char

Parse any single character

char :: Char -> Parser Char

Parse a specific character

digit :: Parser Char

parse a digit character

(+++) :: 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

oneOrMore :: Parser a -> Parser [a]

Parse one or more things

zeroOrMore :: Parser a -> Parser [a]

Parse zero or more things

chain :: Parser a -> Parser b -> Parser [a]

Parse a list of as, separated by bs