[Haskell-cafe] Language extensions

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Sun May 27 17:34:33 EDT 2007


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).

(Aren't you glad you asked?)

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH




More information about the Haskell-Cafe mailing list