Changes between Version 2 and Version 3 of monad-coroutine

Show
Ignore:
Timestamp:
03/21/10 04:34:36 (5 years ago)
Author:
blamario (IP: 99.241.117.248)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • monad-coroutine

    v2 v3  
    1919   fmap f (Yield x y) = Yield x (f y) 
    2020}}} 
     21 
     22A coroutine parameterized by this functor is a generator which yields a value every time it suspends. For example, the following function generates the program's command-line arguments: 
     23 
     24{{{ 
     25 genArgs :: Coroutine (Yield String) IO () 
     26 genArgs = getArgs >>= mapM_ yield 
     27}}} 
     28 
     29The `Await` functor is dual to `Yield`; a coroutine that suspends using this functor is a consumer coroutine that on every suspension expects to be given a value before it resumes. The following example is a consumer coroutine that prints every received value to standard output: 
     30 
     31{{{ 
     32 printer :: Show x => Coroutine (Await x) IO () 
     33 printer = await >>= print >> printer            
     34}}}