Ticket #353: yield-cont-fails.2.hs

File yield-cont-fails.2.hs, 229 bytes (added by laboratoryman, 9 years ago)
Line 
1import Control.Monad.Cont
2
3yield :: a -> Cont [a] ()
4yield x = Cont (\c -> x : c ())
5
6asGenerator :: Cont [a] v -> [a]
7asGenerator (Cont f) = f (const [])
8
9test = asGenerator (yield 0 >> yield 1 >> yield 2)
10
11main = do print test