Open vlopezj opened 10 years ago
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.
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
When using the
Iter
monad, it is common to, at some point, run the computation until it terminates by usingrunIdentity . retract
.This could be implemented as a separate function, named, for example
unsafeIter :: Iter a -> a
, in the same spirit asfromMaybe :: Maybe a -> a
orunsafePerformIO :: IO a -> a
. The unsafe monicker warns that the safety guarantees from theIter
monad are lost, namely, evaluation might not terminate.Any input on the name, the implementation or the usefulness of the proposed function is welcome.