[Haskell] Control.Monad.Writer as Python generator
zednenem at psualum.com
Thu Apr 14 01:05:46 EDT 2005
> I was thinking to myself:
> What in Haskell would give me a "yield" command like a Python
> And the answer was "tell" in Control.Monad.Writer -- and I wrote some
> simple examples (see below).
Another possibility would be a continuation monad.
yield :: a -> Cont [a] ()
yield x = Cont (\c -> x : c ())
asGenerator :: Cont [a] v -> [a]
asGenerator (Cont f) = f (const )
David Menendez <zednenem at psualum.com> | "In this house, we obey the laws
<http://www.eyrie.org/~zednenem> | of thermodynamics!"
More information about the Haskell