Safe Haskell | None |
---|---|
Language | Haskell98 |
- stripParse :: (ParserInput a, Monad m) => Parser a b -> TransducerM (ExceptT (ParsingError a) m) a a b
- parses :: (ParserInput a, Monad m) => Parser a b -> TransducerM (ExceptT (ParsingError a) m) a b ()
- class (Eq a, StableFactorialMonoid a) => ParserInput a
- type ParsingError a = (a, [String], String)
Documentation
stripParse :: (ParserInput a, Monad m) => Parser a b -> TransducerM (ExceptT (ParsingError a) m) a a b Source
Strips from the stream the prefix that matches the parser.
The parsed value becomes the return value of the TransducerM
.
>>>
runExcept $ L.foldM (transduceM (void (stripParse (many (A.char 'a')))) (L.generalize L.mconcat)) (map T.pack ["aa","bb"])
Right "bb"
>>>
runExcept $ L.foldM (transduceM' (stripParse (many (A.char 'a'))) (L.generalize L.mconcat)) (map T.pack ["aa","aa","bb"])
Right ("aaaa","bb")
>>>
runExcept $ L.foldM (transduceM' (stripParse (A.char 'z')) (L.generalize L.mconcat)) (map T.pack ["aa","aa","bb"])
Left ("aa",["'z'"],"Failed reading: satisfy")
parses :: (ParserInput a, Monad m) => Parser a b -> TransducerM (ExceptT (ParsingError a) m) a b () Source
Feeds a FoldM
with the results of repeatedly applying a parser.
>>>
runExcept $ L.foldM (transduceM (parses (A.decimal <* A.char ' ')) (L.generalize L.list)) (map T.pack ["1 1","1 3 77 "])
Right [1,11,3,77]
class (Eq a, StableFactorialMonoid a) => ParserInput a Source
ParserInput ByteString Source | |
ParserInput Text Source | Strict |
type ParsingError a = (a, [String], String) Source
A triplet of (leftovers,error contexts,error message)