|Maintainer||Luke Palmer <email@example.com>|
A monad for enumerating sets: like the list monad, but "breadth-first".
It addresses the problem seen when trying to generate
the list of all pairs of naturals with
[ (x,y) | x <- [0..], y <- [0..] ], which is broken
since the first element of every reachable pair will
Using Omega this can be written
pairs = runOmega $ do x <- each [0..] y <- each [0..] return (x,y)
More precisely, if
x appears at a finite index in
y appears at a finite index in
y will appear at a finite index in
each xs >>= f.
This is the hinge algorithm of the Omega monad,
exposed because it can be useful on its own. Joins
a list of lists with the property that for every x y
there is an n such that
xs !! x !! y == diagonal xs !! n.