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

9.4 migration: getSourcePos now requires Monad m => #532

Closed
simonmichael opened this issue Jun 15, 2023 · 6 comments · Fixed by #533
Closed

9.4 migration: getSourcePos now requires Monad m => #532

simonmichael opened this issue Jun 15, 2023 · 6 comments · Fixed by #533
Labels

Comments

@simonmichael
Copy link

simonmichael commented Jun 15, 2023

Thanks for megaparsec 9.4. I'm testing for commercialhaskell/stackage#7003 , and it seems that a ton of my type signatures now require Monad m =>, because of using getSourcePos (and probably other things). That function's haddock hasn't changed and the changelog doesn't mention this. I'm curious how did it work before, what caused it to change, and is the change necessary ?

@mrkkrp
Copy link
Owner

mrkkrp commented Jun 16, 2023

This change was introduced in #514. In short, now MonadParsec e s (ParsecT e s m) instance requires Monad m, which was always assumed since it is the inner monad in the monad transformer, but now it has to be included in the constraints because of the new method mkParsecT which uses the bind of the inner monad m.

@mrkkrp
Copy link
Owner

mrkkrp commented Jun 16, 2023

I'm curious how did it work before

All methods of MonadParsec worked directly by calling continuations and did not rely on m being a monad, i.e. they did not use monadic bind on m.

is the change necessary

Actually given that mkParsec does not make use of m (unlike mkParsecT) I think the constraint could have been avoided. I just did not think it would be problematic. I could try to remove it if it poses a problem for you.

@mrkkrp
Copy link
Owner

mrkkrp commented Jun 16, 2023

See #533.

@simonmichael
Copy link
Author

simonmichael commented Jun 16, 2023

Thanks Mark. In hledger at least it's quite impactful, it will require changing ("cluttering" ?) 140 type signatures, so I wanted to check it's intended before doing that. I don't know if I'm an outlier here. If it stays, it should probably be added to the changelog. (I didn't find/recognise the responsible change by comparing haddocks either.)

@mrkkrp
Copy link
Owner

mrkkrp commented Jun 16, 2023

Okay, 9.4.1 is on Hackage. It should have the same constraints as in older versions of the library.

@simonmichael
Copy link
Author

Thank you very much!

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

Successfully merging a pull request may close this issue.

2 participants