Version 3 (modified by ross@…, 9 years ago) (diff) |
---|

# Parallel List comprehensions

See ExtensionDescriptionHowto for information on how to write these extension descriptions. Please add any new extensions to the list of HaskellExtensions.

## Brief Explanation

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 `p`_{i} is a tuple of the variables defined by `quals`_{i} and used by `e`.

## References

- Parallel list comprehensions in the GHC User's Guide

## Tickets

- #55
- add Parallel List comprehensions

## Pros

- Easy and well-specified

## Cons

- Not widely used, and not hugely more concise than using explicit zips.
- Naive users can trip over them if they misplace a '
`|`'. - 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]]

- The notation expresses zips of filters and maps, but not filters of zips, which are more common.