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

Provide breakable loops #5

Open
singpolyma opened this issue Jan 25, 2013 · 1 comment
Open

Provide breakable loops #5

singpolyma opened this issue Jan 25, 2013 · 1 comment

Comments

@singpolyma
Copy link

This can be done with EitherT or EitherRT (or similar internal functionality) :

loop f = runEitherT (forever f) >>= (\(Left x) -> return x)

break = left
@mokus0
Copy link
Owner

mokus0 commented May 1, 2016

For this purpose I actually really liked the "loop-while" library on Hackage - it appears not to build any more, but as simple as it is I suspect it just needs its dependency versions loosened. It provides a very nice monad transformer (LoopWhileT) that does exactly this, and gives more informative types while it's at it. The newer loops package looks more complex but is probably also a good alternative.

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