[Haskell-beginners] Factor out parsec types
Francesco Ariis
fa-ml at ariis.it
Tue Mar 24 16:26:55 UTC 2020
Hello Max,
On Tue, Mar 24, 2020 at 04:06:03PM +0100, Max Gautier wrote:
> 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...
Is there any reason you are using `St s => s ...` rather than a concrete
type?
If not,
type MyPar a = ParsecT Char () Identity a
p :: MyPar Int
could be useful. Does that work for you?
-F
More information about the Beginners
mailing list