Removing MonadFail from Monad
David Luposchainsky
dluposchainsky at googlemail.com
Tue Dec 17 13:18:25 UTC 2013
On 17.12.2013 14:09, Tom Ellis wrote:
>> AFAIK, it was done this way for list comprehensions. Currently, you can
>> write e.g.
>>
>>> rights = [x | Right x <- listOfEithers]
>>
>> and it works properly.
>
> Sure, but that then just raises the question "why was this special case
> added for list comprehensions"?
List comprehensions are special.
- They have their own semantics in the report. Desugaring them to `do`
notation is a possible implementation, but I think GHC doesn't do that
for performance reasons (-XMonadComprehensions changes this).
- List comprehensions can always rely on the empty list to exist, there
is no analogon to this in an arbitrary monad. Translations to `do`
notation should leave semantics invariant.
David
More information about the Libraries
mailing list