[Haskell-beginners] Factor out parsec types

Max Gautier ashelia1000 at gmail.com
Tue Mar 24 15:06:03 UTC 2020


I'm writing a parser for polynomial equation (ex : 5 x ^2 + 3 x ^ 1 = 3 x ^
2).

I'm using parsec to decompose my parser into smaller parts, and it works,
but all my parser functions have the type :
parser :: Stream s m Char => ParsecT s u m <Type to Parse>

Is there a way to factor out that boilerplate, in such a way that I could
simply write a type like
parser :: Parser <Type to parse>
?

The farther I've been is :
type Parser s = ParsecT s () Identity
type St = Stream s Identity Char (using ConstraintKinds)
parser :: St s => Parser s <Type to Parse>

But that still feels tedious to write every time...

I've tried to search the wiki and the internet in general, but did not find
an answer to that particularly.

Thxs a lot if you have any hindsights.

Max Gautier
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20200324/f1d69fce/attachment.html>


More information about the Beginners mailing list