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] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon university    KF8NH


_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to