[Haskell-cafe] Language extensions
Ilya Tsindlekht
eilya497 at 013.net
Mon May 28 04:58:27 EDT 2007
On Sun, May 27, 2007 at 05:34:33PM -0400, Brandon S. Allbery KF8NH wrote:
>
> On May 27, 2007, at 17:23 , Andrew Coppin wrote:
>
> >Personally, I try to avoid ever using list comprehensions. But
> >every now and then I discover an expression which is apparently not
> >expressible without them - which is odd, considering they're only
> >"sugar"...
>
> They are. But they're sugar for monadic operations in the list
> monad, so you have to use (>>=) and company to desugar them. [x |
> filter even x, x <- [1..10]] becomes do { x <- [1..10]; return
> (filter even x) } becomes ([1..10] >>= return . filter even).
>
The list monad is easily defineable in pure Haskell, so one can do
without monadic operation as well if one wishes to.
More information about the Haskell-Cafe
mailing list