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

Add specialization of retract for Iter ~ IterT Identity #75

Open
vlopezj opened this issue Jul 14, 2014 · 2 comments
Open

Add specialization of retract for Iter ~ IterT Identity #75

vlopezj opened this issue Jul 14, 2014 · 2 comments

Comments

@vlopezj
Copy link
Collaborator

vlopezj commented Jul 14, 2014

When using the Iter monad, it is common to, at some point, run the computation until it terminates by using runIdentity . retract.

This could be implemented as a separate function, named, for example unsafeIter :: Iter a -> a, in the same spirit as fromMaybe :: Maybe a -> a or unsafePerformIO :: IO a -> a. The unsafe monicker warns that the safety guarantees from the Iter monad are lost, namely, evaluation might not terminate.

Any input on the name, the implementation or the usefulness of the proposed function is welcome.

@ekmett
Copy link
Owner

ekmett commented Mar 7, 2015

I'm not so keen on the 'unsafe' name, but I have no objection to adding an operation with a name that clearly indicates it runs to completion.

@vlopezj
Copy link
Collaborator Author

vlopezj commented Mar 23, 2015

How about whileRight or untilLeft? Either standalone, or prefixed with run, runIter or iter.

The probability package uses untilLeft [1]. According to Google, the other alternatives are not used by any other Hackage package.

[1] https://hackage.haskell.org/package/probability-0.2.4.1/docs/Numeric-Probability-Transition.html

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