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

MonadFix instance is needlessly strict #2

Closed
gergoerdi opened this issue Dec 15, 2015 · 1 comment
Closed

MonadFix instance is needlessly strict #2

gergoerdi opened this issue Dec 15, 2015 · 1 comment

Comments

@gergoerdi
Copy link

As explained on http://stackoverflow.com/a/34287498/477476 , RevState's MonadFix instance is too strict and is practically unusable as a result. The fix is a trivial matter of using an irrefutable pattern in the instance definition; i.e. going from

instance MonadFix m => MonadFix (StateT s m) where
  mfix f = StateT $ \s -> mfix (\(x, _) -> runStateT (f x) s)

to

instance MonadFix m => MonadFix (StateT s m) where
  mfix f = StateT $ \s -> mfix (\ ~(x, _) -> runStateT (f x) s)
@DanBurton
Copy link
Owner

Thanks for the bugfix! I've whipped up a little test suite based on the example in that SO question.

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