Changes between Version 3 and Version 4 of monad-coroutine

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

--

Legend:

Unmodified
Added
Removed
Modified
  • monad-coroutine

    v3 v4  
    55 
    66{{{ 
    7 newtype Coroutine s m r = Coroutine {resume :: m (Either (s (Coroutine s m r)) r)} 
     7 newtype Coroutine s m r = Coroutine {resume :: m (Either (s (Coroutine s m r)) r)} 
    88 
    9 instance (Functor s, Monad m) => Monad (Coroutine s m) where 
     9 instance (Functor s, Monad m) => Monad (Coroutine s m) where 
    1010   return = Coroutine . return . Right 
    1111   t >>= f = Coroutine (resume t >>= either (return . Left . fmap (>>= f)) (resume . f)) 
    1212}}} 
    1313 
     14== Suspension Functors == 
     15 
    1416The Coroutine transformer type is parameterized by a functor. The functor in question wraps the resumption of a suspended coroutine, and it can carry other information as well. Module `Control.Monad.Coroutine.SuspensionFunctors` exports some useful functors, one of which is `Yield`: 
    1517 
    1618{{{ 
    17 data Yield x y = Yield x y 
    18 instance Functor (Yield x) where 
     19 data Yield x y = Yield x y 
     20 instance Functor (Yield x) where 
    1921   fmap f (Yield x y) = Yield x (f y) 
    2022}}} 
     
    3335 printer = await >>= print >> printer            
    3436}}} 
     37 
     38== Running a coroutine == 
     39