[Haskell-cafe] Re: generalized list comprehensions

Max Bolingbroke batterseapower at hotmail.com
Mon Nov 10 05:59:56 EST 2008

2008/11/10 Johannes Waldmann <waldmann at imn.htwk-leipzig.de>:
> Well, my original post wasn't that negative ...
> Indeed "then f [by e]" seems a nice idea *but*
> the point was that I'd like to have this in any monad.
> The type of f in "then f" should be  m a -> m b, not just m a -> m a,
> because then you don't need special syntax for "group",
> which is somewhat like [a] -> [[a]] ?

Hi Johannes,

I'm not sure what it would mean for f to have type m a -> m b. The
point of the parametric polymorphism in the type forall a. m a -> m b
is that the "f" function is guarenteed not to inspect the structure of
the (list/monad) element. This allows the compiler to choose a
representation for the intermediate tuples used in the desugaring
freely. The "group" syntax really does desugar differently from "then"
because the compiler inserts an extra unzip_n that the user could not
have written, given that parametric polymorphism.

All the best,

More information about the Haskell-Cafe mailing list