-
Notifications
You must be signed in to change notification settings - Fork 65
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
Change semantics for IterT's Alternative and MonadPlus instances #52
Comments
We can do that with a major version bump and a clearly worded |
On the other hand, this new instances are not fully satisfactory. Ideally, if the underlying monad implements MonadPlus, the first computation which completes and does so without errors should be returned. The instance for plain IterT Identity (which is not MonadPlus) is quite straightforward, and causes no conflicts. I'll add that one first, and then think whether it's possible to make IterT into a true MonadPlus transformer. |
The problem with making instances for Of course we can make a separate data Iter a = Stop a | Step (Iter a) with obvious racing. |
The behaviour described above is now in commit 7b3cbcb , on the The approach is similar to the one for the |
I'm cautiously optimistic about the new change. The main question I'd have is how to get the word out about it. |
How about some explanation at the top of the Haddock page, and an usage example? Together with the major version bump, it could be enough for interested users to notice. |
That sounds like a plan to me. Feel free to merge into master. On Wed, Jul 9, 2014 at 11:21 AM, Víctor López Juan <notifications@github.com
|
Have I mentioned that you, sir, are awesome? |
These are the current instances for
IterT
ofAlternative
andMonadPlus
. Both of them were added when theIter
module was first commited; they are equivalent to the ones that would be created byGeneralizedNewtypeDeriving
.In Capretta's slides, a
race
function is defined. It tries several approaches for the same result (some of them, maybe non terminating), and the earliest one to succeed is picked out.Venanzio b
is equivalent toIter b
.If
race
is generalized to theIterT m b
, the following instances can be defined. They are analogous to the ones for theMaybeT
transformer, and satisfy the same subset of laws : namely, monad plus with left catch.These new semantics might be more useful, but they would break the API.
The text was updated successfully, but these errors were encountered: