Portability  portable 

Stability  provisional 
Maintainer  gcross@phys.washington.edu 
Safe Haskell  SafeInfered 
This module provides a monad and a monad transformer that allow the user to transfer the flow of execution from an arbitrary point of a monadic computation to another monadic computation.
The Goto monad
type Goto r = GotoT r IdentitySource
A goto monad, parameterized by the type r
of the value to return.
:: Goto r r  the monadic computation to run 
> r  the result of the computation 
Execute the goto monad computation and return the resulting value.
The GotoT monad transformer
A goto monad transformer parameterized by

r
 the value that will ultimately be returned; and 
m
 the inner monad.
The GotoT
type wraps a monadic value that contains either a pure value or
the next place at which the flow of execution should be continued.
GotoT  

MonadTrans (GotoT r)  
Monad m => Monad (GotoT r m)  
Functor m => Functor (GotoT r m)  
Applicative m => Applicative (GotoT r m)  
MonadIO m => MonadIO (GotoT r m) 
Execute the goto monad computation and return the resulting value.
runGotoT
is implemented by using a ''trampoline'' approach. It
looks at the monadic value and checks whether it is either a Left
containing a continuation or a Right
containing the result. As
long as it sees a Left
it executes the continuation and then
feeds the result back into itself. Thus the computation bounces
back to this function (hence the ''trampoline'') as long as the
user keeps calling goto
until the final result has been obtained.
Goto operations
:: Monad m  
=> GotoT r m r  the destination to which to transfer the flow of execution 
> GotoT r m a  a monadic value that has the effect of transferring the flow of execution to the specified destination; note that value can have an arbitrary type since it will never actually be accessed 
Transfer the flow of executation from an arbitrary point in the current monadic computation to another monadic computation.
Note that the destination computation must promise to produce the same value that was promised to be returned by the origin computation. Also, since control is being transferred away from the origin computation, the goto function returns a monadic value that can have an arbitrary type, since the monadic value will never be used by the originating computation.