Skip to content

[Patch] Support implicit concatenation in list comprehensions

Using the -XImplicitConcatListComp option turns on implicit concatenation in list comprehensions. What this means is that you can write several things separated by commas in the "body" of a list comprehension, like so

[x, x | x <- [1..10], x `mod` 2 == 0]

This program produces the following output

[2, 2, 4, 4, 6, 6, 8, 8]

The effect is the same as if you had written

concat [[x, x] | x &lt;- [1..10], x `mod` 2 == 0]

but more concise, and more likely to be optimised well by the compiler.

NB: this was originally proposed in the SQL-like list comprehensions paper.

Trac metadata
Trac field Value
Version 6.10.4
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information