Module DetParser

A library with deterministic parser combinators.

Might be moved into a separate package in the future.

Summary of exported operations:

(<*) :: ([a] -> Either String ([a],b)) -> ([a] -> Either String ([a],c)) -> [a] -> Either String ([a],b)  Deterministic 
Combine parsers with resulting representation of first one.
(*>) :: ([a] -> Either String ([a],b)) -> ([a] -> Either String ([a],c)) -> [a] -> Either String ([a],c)  Deterministic 
Combine parsers with resulting representation of second one.
(<*>) :: ([a] -> Either String ([a],b -> c)) -> ([a] -> Either String ([a],b)) -> [a] -> Either String ([a],c)  Deterministic 
(<|>) :: ([a] -> Either String ([a],b)) -> ([a] -> Either String ([a],b)) -> [a] -> Either String ([a],b)  Deterministic 
Combines two parsers in an alternative manner.
(<$>) :: (a -> b) -> ([c] -> Either String ([c],a)) -> [c] -> Either String ([c],b)  Deterministic 
Apply unary function f to result of parser p
liftP2 :: (a -> b -> c) -> ([d] -> Either String ([d],a)) -> ([d] -> Either String ([d],b)) -> [d] -> Either String ([d],c)  Deterministic 
Apply binary function f to results of parsers p1 and p2
yield :: a -> [b] -> Either String ([b],a)  Deterministic 
A parser with x as representation while consuming no tokens.
terminal :: (Eq a, Show a) => a -> [a] -> Either String ([a],())  Deterministic 
A parser recognizing a particular terminal symbol.
eof :: [a] -> Either String ([a],b)  Deterministic 
Returns parse error about unexpected end-of-file
unexpected :: Show a => a -> [a] -> Either String ([a],b)  Deterministic 
Returns parse error about unexpected token t
star :: ([a] -> Either String ([a],b)) -> [a] -> Either String ([a],[b])  Deterministic 
A star combinator for parsers.
some :: ([a] -> Either String ([a],b)) -> [a] -> Either String ([a],[b])  Deterministic 
A some combinator for parsers.

Exported datatypes:


Parser

Type synonym: Parser a b = [a] -> Either ParseError ([a],b)


ParseError

Type synonym: ParseError = String


Exported operations:

(<*) :: ([a] -> Either String ([a],b)) -> ([a] -> Either String ([a],c)) -> [a] -> Either String ([a],b)  Deterministic 

Combine parsers with resulting representation of first one.

(*>) :: ([a] -> Either String ([a],b)) -> ([a] -> Either String ([a],c)) -> [a] -> Either String ([a],c)  Deterministic 

Combine parsers with resulting representation of second one.

(<*>) :: ([a] -> Either String ([a],b -> c)) -> ([a] -> Either String ([a],b)) -> [a] -> Either String ([a],c)  Deterministic 

(<|>) :: ([a] -> Either String ([a],b)) -> ([a] -> Either String ([a],b)) -> [a] -> Either String ([a],b)  Deterministic 

Combines two parsers in an alternative manner.

(<$>) :: (a -> b) -> ([c] -> Either String ([c],a)) -> [c] -> Either String ([c],b)  Deterministic 

Apply unary function f to result of parser p

liftP2 :: (a -> b -> c) -> ([d] -> Either String ([d],a)) -> ([d] -> Either String ([d],b)) -> [d] -> Either String ([d],c)  Deterministic 

Apply binary function f to results of parsers p1 and p2

yield :: a -> [b] -> Either String ([b],a)  Deterministic 

A parser with x as representation while consuming no tokens.

Further infos:
  • solution complete, i.e., able to compute all solutions

terminal :: (Eq a, Show a) => a -> [a] -> Either String ([a],())  Deterministic 

A parser recognizing a particular terminal symbol.

eof :: [a] -> Either String ([a],b)  Deterministic 

Returns parse error about unexpected end-of-file

Further infos:
  • solution complete, i.e., able to compute all solutions

unexpected :: Show a => a -> [a] -> Either String ([a],b)  Deterministic 

Returns parse error about unexpected token t

star :: ([a] -> Either String ([a],b)) -> [a] -> Either String ([a],[b])  Deterministic 

A star combinator for parsers. The returned parser repeats zero or more times a parser p and returns the representation of all parsers in a list.

some :: ([a] -> Either String ([a],b)) -> [a] -> Either String ([a],[b])  Deterministic 

A some combinator for parsers. The returned parser repeats the argument parser at least once.