
17 Dec
2013
17 Dec
'13
8:18 a.m.
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