 monadcoroutine0.5: Coroutine monad transformer for suspending and resuming monadic computations  Source code  Contents  Index 

Control.Monad.Coroutine.Nested 


Description 
This module defines nestable suspension functors for use with the Coroutine monad transformer, as well as
functions for running nested coroutines of this sort.
Coroutines can be run from within another coroutine. In this case, the nested coroutines always suspend to their
invoker. If a function from this module, such as pogoStickNested, is used to run a nested coroutine, the parent
coroutine can be automatically suspended as well. A single suspension can thus suspend an entire chain of nested
coroutines.
Nestable coroutines of this kind should group their suspension functors into an EitherFunctor. You can adjust a
normal suspension, such as the one produced by yield, using functions mapSuspension and liftOut. To run nested
coroutines, use functions pogoStickNested, seesawNested, and coupleNested.


Synopsis 

pogoStickNested :: forall s1 s2 m x. (Functor s1, Functor s2, Monad m) => (s2 (Coroutine (EitherFunctor s1 s2) m x) > Coroutine (EitherFunctor s1 s2) m x) > Coroutine (EitherFunctor s1 s2) m x > Coroutine s1 m x   coupleNested :: forall s0 s1 s2 m x y r. (Monad m, Functor s0, Monad s0, Functor s1, Functor s2) => (forall x y r. (x > y > m r) > m x > m y > m r) > Coroutine (EitherFunctor s0 s1) m x > Coroutine (EitherFunctor s0 s2) m y > Coroutine (EitherFunctor s0 (SomeFunctor s1 s2)) m (x, y)   seesawNested :: (Monad m, Functor s0, Functor s1, Functor s2) => (forall x y r. (x > y > m r) > m x > m y > m r) > SeesawResolver s1 s2 > Coroutine (EitherFunctor s0 s1) m x > Coroutine (EitherFunctor s0 s2) m y > Coroutine s0 m (x, y)   class (Functor a, Functor d) => AncestorFunctor a d   liftOut :: forall m a d x. (Monad m, Functor a, AncestorFunctor a d) => Coroutine a m x > Coroutine d m x 


Documentation 


Run a nested Coroutine that can suspend both itself and the current Coroutine.



Weaves two nested coroutines into one.



Like seesaw, but for nested coroutines that are allowed to suspend the current coroutine as well as themselves.
If both coroutines try to suspend the current coroutine in the same step, the left coroutine's suspension will have
precedence.



Class of functors that can be lifted.
  Instances  



Converts a coroutine into a descendant nested coroutine.


Produced by Haddock version 2.7.2 