[Haskell-cafe] Is the Haskell list comprehension just a Cartesian product machine?

Viktor Dukhovni ietf-dane at dukhovni.org
Wed Dec 8 03:37:47 UTC 2021


On Tue, Dec 07, 2021 at 09:46:48PM -0500, Albert Y. C. Lai wrote:

> Level 1:
> ...
> Level 2:
> ...
> Level 3:
> ...

And we haven't even touched either of:

    {-# LANGUAGE ParallelListComp #-}
    {-# LANGUAGE TransformListComp #-}

or the fact that in the dependent case, we might not output anything
that feels like a product:

    concat :: [[a]] -> [a]
    concat xss = [ x | xs <- xss, x <- xs ]

So indeed list comprehensions are products in the simplest cases, and do
generate nested loops under various conditions, but they're considerly
more flexible.

-- 
    Viktor.


More information about the Haskell-Cafe mailing list