[Haskell-cafe] generalized list comprehensions

Max Bolingbroke batterseapower at hotmail.com
Sat Nov 8 18:43:52 EST 2008

2008/11/8 Johannes Waldmann <waldmann at imn.htwk-leipzig.de>:
> Looking at this funny new feature
> http://haskell.org/ghc/docs/6.10.1/html/users_guide/syntax-extns.html#generalised-list-comprehensions
> I have just one question - why doesn't this work with the do-notation?
> I avoid list comprehensions because I feel that
> "return" belongs at the end, not in front.
> If I recall correctly, "putting the SQL-select where it belongs"
> is a slogan used by Hijlsberg to justify the LINQ syntax for C#,
> and of course he is right.
> Now ghc copies LINQ (syntactically), but stops halfway?

Hi Johannes,

There is no technical reason the syntax could not be extended to do
notation - see the discussion by Michael Adams on the
http://haskell.org/haskellwiki/Simonpj/Talk:ListComp page for a taste
of how that would work (note that his translation is however not
totally correct, IIRC). The only reason that I didn't actually
implement this feature is that neither I nor SPJ could think of a use
case for this syntax outside the list monad. I don't think we
considered the possibility you might use do notation for the list
monad, as it's not an idiom that seems to occur often.

If you can come up with such a use case I could probably find the time
to implement the extra translation steps! On reflection, it does seem
a bit like an annoying irregularity to the implementation.


More information about the Haskell-Cafe mailing list