|Version 6 (modified by ross@…, 8 years ago) (diff)|
Parallel List comprehensions
Parallel comprehensions extend list comprehensions with a notation for zips. The comprehension
[ e | quals1 | ... | qualsN ]
can be desugared to
zipWithN (\ p1 ... pN -> e) [p1 | quals1] ... [pN | qualsN]
where pi is a tuple of the variables defined by qualsi and used by e.
- Parallel list comprehensions in the GHC User's Guide
- add Parallel List comprehensions
- Easy and well-specified.
- Expresses zips of filters, which are tricky to express with standard list comprehensions.
- Those who use them do so heavily, e.g. there are 142 uses of parallel list comprehensions in the jhc source tree.
- Most people do not find them useful, and find the only slightly longer version using explicit zips clearer.
- Naive users can trip over them if they misplace a '|'.
- Limited, e.g. cannot express filters of zips, which are more common.
- In its more general forms it's hard to predict how the elements from each set of generators and filters will match up, e.g.
[(i,j,k) | i <- [1..3], j <- [1..3] | k <- [1..9]]