Compile your free monad into another language by changing the
suspension functor using the given natural transformation f
.
Compile your free monad into another language by changing the
suspension functor using the given natural transformation f
.
If your natural transformation is effectful, be careful. These
effects will be applied by compile
.
Bind the given continuation to the result of this computation.
Bind the given continuation to the result of this computation. All left-associated binds are reassociated to the right.
Catamorphism.
Catamorphism. Run the first given function if Pure, otherwise, the second given function.
Catamorphism for Free
.
Catamorphism for Free
.
Run to completion, mapping the suspension with the given
transformation at each step and accumulating into the monad M
.
This method uses tailRecM
to provide stack-safety.
Run to completion, using a function that extracts the resumption from its suspension functor.
Lift into G
(typically a EitherK
) given InjectK
.
Lift into G
(typically a EitherK
) given InjectK
. Analogous
to Free.inject
but lifts programs rather than constructors.
scala> type Lo[A] = cats.data.EitherK[List, Option, A] defined type alias Lo scala> val fo = Free.liftF(Option("foo")) fo: cats.free.Free[Option,String] = Free(...) scala> fo.inject[Lo] res4: cats.free.Free[Lo,String] = Free(...)
Modify the functor context S
using transformation f
.
Modify the functor context S
using transformation f
.
This is effectively compiling your free monad into another
language by changing the suspension functor using the given
natural transformation f
.
If your natural transformation is effectful, be careful. These
effects will be applied by mapK
.
Evaluate a single layer of the free monad.
Evaluate a single layer of the free monad.
Run to completion, using the given comonad to extract the resumption.
Run to completion, using a function that maps the resumption
from S
to a monad M
.
Run to completion, using monadic recursion to evaluate the
resumption in the context of S
.
Takes one evaluation step in the Free monad, re-associating left-nested binds in the process.
Takes one evaluation step in the Free monad, re-associating left-nested binds in the process.
A free operational monad for some functor
S
. Binding is done using the heap instead of the stack, allowing tail-call elimination.