Parsing. Parser. Combinators
Combinators for creating parsers.
A few of the known combinators from Parsec are missing in this module. That is because they have already been defined in other libraries.
Text.Parsec.many = Data.(Array|List).many Text.Parsec.(<|>) = Control.Alt.alt (<|>)
Because Strings are not Char Arrays in PureScript
some on Char Parsers need to
be used in conjunction with
Data.String.CodeUnits.fromCharArray to achieve "Parsec-like" results.
Text.Parsec.many (char 'x') <=> fromCharArray <$> Data.Array.many (char 'x')
Data.(Array|List).(many|some) are not stack safe. If you need to parse
large numbers of items then consider using
Operator alias for Text.Parsing.Parser.Combinators.withErrorMessage (left-associative / precedence 3)
Provide an error message in the case of failure, but lazily. This is handy in cases where constructing the error message is expensive, so it's preferable to defer it until an error actually happens.
parseBang :: Parser Char parseBang = char '!' <~?> \_ -> "Expected a bang"
Operator alias for Text.Parsing.Parser.Combinators.withLazyErrorMessage (left-associative / precedence 3)
Operator alias for Text.Parsing.Parser.Combinators.asErrorMessage (left-associative / precedence 3)