ChrisK writes: > I was thinking to myself: > What in Haskell would give me a "yield" command like a Python > generator? > > And the answer was "tell" in Control.Monad.Writer -- and I wrote some > simple examples (see below).
Another possibility would be a continuation monad. import Control.Monad.Cont yield :: a -> Cont [a] () yield x = Cont (\c -> x : c ()) asGenerator :: Cont [a] v -> [a] asGenerator (Cont f) = f (const []) -- David Menendez <[EMAIL PROTECTED]> | "In this house, we obey the laws <http://www.eyrie.org/~zednenem> | of thermodynamics!" _______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell