
28 May
2007
28 May
'07
8:58 a.m.
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.