Safe Haskell | None |
---|
- newtype Parser e tok a = Parser {}
- data PrinterParser e tok a b = PrinterParser {}
- (.~) :: PrinterParser e tok a b -> PrinterParser e tok b c -> PrinterParser e tok a c
- parse :: forall e a p tok. InitialPosition e => PrinterParser e tok () a -> tok -> [Either e (a, tok)]
- parse1 :: (ErrorPosition e, InitialPosition e, Show e, Ord (Pos e)) => (tok -> Bool) -> PrinterParser e tok () (a :- ()) -> tok -> Either [e] a
- unparse :: tok -> PrinterParser e tok () url -> url -> [tok]
- unparse1 :: tok -> PrinterParser e tok () (a :- ()) -> a -> Maybe tok
- bestErrors :: (ErrorPosition e, Ord (Pos e)) => [e] -> [e]
- xpure :: (a -> b) -> (b -> Maybe a) -> PrinterParser e tok a b
- val :: forall e tok a r. Parser e tok a -> (a -> [tok -> tok]) -> PrinterParser e tok r (a :- r)
- xmap :: (a -> b) -> (b -> Maybe a) -> PrinterParser e tok r a -> PrinterParser e tok r b
- xmaph :: (a -> b) -> (b -> Maybe a) -> PrinterParser e tok i (a :- o) -> PrinterParser e tok i (b :- o)
Types
Yet another parser.
Returns all possible parses and parse errors
data PrinterParser e tok a b Source
A PrinterParser a b
takes an a
to parse a URL and results in b
if parsing succeeds.
And it takes a b
to serialize to a URL and results in a
if serializing succeeds.
Category (PrinterParser e tok) | |
~ * a b => IsString (PrinterParser StringError String a b) | |
~ * a b => IsString (PrinterParser StringsError [String] a b) | |
Monoid (PrinterParser e tok a b) |
(.~) :: PrinterParser e tok a b -> PrinterParser e tok b c -> PrinterParser e tok a cSource
Reverse composition, but with the side effects still in left-to-right order.
Running routers
parse :: forall e a p tok. InitialPosition e => PrinterParser e tok () a -> tok -> [Either e (a, tok)]Source
Give all possible parses or errors.
parse1 :: (ErrorPosition e, InitialPosition e, Show e, Ord (Pos e)) => (tok -> Bool) -> PrinterParser e tok () (a :- ()) -> tok -> Either [e] aSource
Give the first parse, for PrinterParsers with a parser that yields just one value. Otherwise return the error (or errors) with the highest error position.
unparse :: tok -> PrinterParser e tok () url -> url -> [tok]Source
Give all possible serializations.
unparse1 :: tok -> PrinterParser e tok () (a :- ()) -> a -> Maybe tokSource
Give the first serialization, for PrinterParsers with a serializer that needs just one value.
bestErrors :: (ErrorPosition e, Ord (Pos e)) => [e] -> [e]Source
Attempt to extract the most relevant errors from a list of parse errors.
The current heuristic is to find error (or errors) where the error position is highest.
Constructing / Manipulating PrinterParsers
xpure :: (a -> b) -> (b -> Maybe a) -> PrinterParser e tok a bSource
Lift a constructor-destructor pair to a pure router.
val :: forall e tok a r. Parser e tok a -> (a -> [tok -> tok]) -> PrinterParser e tok r (a :- r)Source
lift a Parser
and a printer into a PrinterParser
xmap :: (a -> b) -> (b -> Maybe a) -> PrinterParser e tok r a -> PrinterParser e tok r bSource
Map over routers.
xmaph :: (a -> b) -> (b -> Maybe a) -> PrinterParser e tok i (a :- o) -> PrinterParser e tok i (b :- o)Source
Like xmap, but only maps over the top of the stack.