Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop the redundant r from the definition of Parser #33

Closed
nikita-volkov opened this issue Apr 12, 2015 · 3 comments
Closed

Drop the redundant r from the definition of Parser #33

nikita-volkov opened this issue Apr 12, 2015 · 3 comments

Comments

@nikita-volkov
Copy link

Currently it's impossible to use Parser in a monad-transformer stack. In cases like the following:

type MyParser s b m a = StateT s (Pipes.Parse.Parser b m) a

the compiler complains with:

Type synonym ‘Pipes.Parse.Parser’ should have 3 arguments, but has been given 2

So I suggest to remove the redundant r from the definition of Parser:

- type Parser a m r = forall x . StateT (Producer a m x) m r
+ type Parser a m = forall x . StateT (Producer a m x) m

Of course, it's possible to work around the issue by expanding the type synonym in place, but it's still an issue.

@Gabriella439
Copy link
Owner

This doesn't work (the library won't compile if you delete the r on both sides), because now you're universally quantifying a higher-kinded type, which is almost always not going to behave well.

The reason this causes problems is that if you write:

Parser a m r

... the compiler will expand it to:

(forall x . StateT (Producer a m x) m) r

... which is not the same thing as:

forall x . StateT (Producer a m x) m r

@nikita-volkov
Copy link
Author

Sorry. My bad.

@Gabriella439
Copy link
Owner

No problem at all! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants