[Haskell-cafe] generalized list comprehensions

Johannes Waldmann waldmann at imn.htwk-leipzig.de
Sun Nov 9 06:40:02 EST 2008

> like [(x, y) | x <- xs | y <- ys], and it's not clear how to define
> "zip" for a monad - but perhaps there is some extension of a monad
> where it makes sense?

Well, I question that the above notation makes sense (for lists).
It is trying to be too clever.

"standard" list comprehensions  at least are consistent
with mathematical notation for sets. (That is,
they are putting the cart before the horse consistently.)

But could you show the above code example to some non-ghc-aware person
and expect her to guess the meaning correctly?  I think not.

And even if, the implied zip is dangerous because it does not
complain about unequal lengths, and you cannot guess that either.
If you write  (x,y) <- zip xs ys  instead then at least you know
that you need to lookup the definition of zip.

Best regards, J.W.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 257 bytes
Desc: OpenPGP digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081109/368307d6/signature.bin

More information about the Haskell-Cafe mailing list