The current Monoid instance of the Trifecta parser is too trivial to be useful:
instance Monoid (Parser a) where
mappend = (<|>)
mempty = empty
A much more useful instance would be:
instance Monoid a => Monoid (Parser a) where
mappend = liftA2 mappend
mempty = pure mempty
This instance could, in fact, be added to the parsers library. Here's a simple example of use:
decimal :: Parser String
decimal = some digit <> option "" (string "." <> some digit)
Note that the instance becomes even more useful with some additional combinators, such as moptional, concatMany, and concatSome from the incremental-parser package. But that's an optional extension.
The current Monoid instance of the Trifecta parser is too trivial to be useful:
instance Monoid (Parser a) where
mappend = (<|>)
mempty = empty
A much more useful instance would be:
instance Monoid a => Monoid (Parser a) where
mappend = liftA2 mappend
mempty = pure mempty
This instance could, in fact, be added to the parsers library. Here's a simple example of use:
decimal :: Parser String
decimal = some digit <> option "" (string "." <> some digit)
Note that the instance becomes even more useful with some additional combinators, such as moptional, concatMany, and concatSome from the incremental-parser package. But that's an optional extension.