[Haskell-cafe] Implicit concatenation in list comprehensions
tphyahoo at gmail.com
Sun Jul 19 11:18:48 EDT 2009
I vote for tuple sections. Very nice!
I don't really see immediate places where I would use the list
comprehension improvement so I guess I don't vote for that.
2009/7/19 Neil Mitchell <ndmitchell at gmail.com>:
> Hi Max,
>> For fun, I spent a few hours yesterday implement support for this
>> syntax in GHC, originally propsed by Koen Claessen:
>>>>> [k, "=", v, " " | (k, v) <- [("foo", "1"), ("bar", "2")]
>> ["foo", "=", "1", " ", "bar", "=", "2", " "]
>> This is a generalisation of list comprehensions that allows several
>> items to be concatenated onto the result list at once, by having
>> several comma-separated items before the pipe.
> I like the power this feature gives, and if it was already in Haskell
> 98 I'd certainly have used it a few times. I can't think of anything
> else the syntax could mean, so I don't see a potential for it stealing
> syntax that might otherwise be reused. However, it doesn't seem that
> discoverable or natural - I'm not sure I'd have ever guessed that such
> a feature might exist.
>> P.S. I also implemented tuple sections
>> (http://hackage.haskell.org/trac/ghc/ticket/3377#comment:3) which are
>> a lot more useful:
> Yay! Discoverable, useful and really common in practice - a brilliant
> extension :-)
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe