
On Tue, Dec 17, 2013 at 8:18 AM, David Luposchainsky
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 weren't special (i.e. specific to lists) in Haskell 1.4. They worked like monad comprehensions. Then they were changed to only work with lists in Haskell98 (and that is still the way the standard is), which is why you need to enable an extension to get monad comprehensions now (that it has been re-implemented). And comprehensions, of course, have failure as a built-in notion, due to guards. This was handled by MonadZero, as was pattern match failure. There was also a definition of unfailable patterns. A pattern was unfailable if it could not be refuted except possibly by partially defined values, as I recall. This makes irrefutable patterns trivially unfailable, if you wish to force the issue. And GHC pretty clearly still implements things this way, as seen in adam vogt's mail. -- Dan