[Haskell-cafe] Re: Fair diagonals

Heinrich Apfelmus apfelmus at quantentunnel.de
Wed Nov 4 09:56:28 EST 2009

Luke Palmer wrote:
> I believe you can get what you want using the diagonal function from
> Control.Monad.Omega.
> product xs ys = [ [ (x,y) | y <- ys ] | x <- xs ]
> diag2 xs ys = diagonal (product xs ys)
> I think if you separate taking the cartesian product and flattening
> it, like this, you might have an easier time wrangling all the
> different variants you want.

Note that Control.Monad.Omega  is not a monad. The law of associativity
is broken, at least in a direct sense.



More information about the Haskell-Cafe mailing list