sealed abstract class Free[S[_], A] extends Product with Serializable with FreeFoldStep[S, A]
A free operational monad for some functor S
. Binding is done
using the heap instead of the stack, allowing tail-call
elimination.
- Source
- Free.scala
- Alphabetic
- By Inheritance
- Free
- FreeFoldStep
- Serializable
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @IntrinsicCandidate()
-
final
def
compile[T[_]](f: FunctionK[S, T]): Free[T, A]
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
. -
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
flatMap[B](f: (A) ⇒ Free[S, B]): Free[S, B]
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.
-
final
def
fold[B](r: (A) ⇒ B, s: (S[Free[S, A]]) ⇒ B)(implicit S: Functor[S]): B
Catamorphism.
Catamorphism. Run the first given function if Pure, otherwise, the second given function.
-
final
def
foldLeft[B](fa: Free[S, A], b: B)(f: (B, A) ⇒ B)(implicit F: Foldable[S]): B
- Definition Classes
- FreeFoldStep
-
final
def
foldMap[M[_]](f: FunctionK[S, M])(implicit M: Monad[M]): M[A]
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. -
final
def
foldRight[B](fa: Free[S, A], lb: Eval[B])(f: (A, Eval[B]) ⇒ Eval[B])(implicit F: Foldable[S]): Eval[B]
- Definition Classes
- FreeFoldStep
-
final
def
foldStep[B](onPure: (A) ⇒ B, onSuspend: (S[A]) ⇒ B, onFlatMapped: ((S[X], (X) ⇒ Free[S, A]) forSome {type X}) ⇒ B): B
A combination of step and fold.
A combination of step and fold. May be used to define interpreters with custom (non-monoidial) control flow.
- Definition Classes
- FreeFoldStep
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
-
final
def
go(f: (S[Free[S, A]]) ⇒ Free[S, A])(implicit S: Functor[S]): A
Run to completion, using a function that extracts the resumption from its suspension functor.
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
-
final
def
inject[G[_]](implicit ev: InjectK[S, G]): Free[G, A]
Lift into
G
(typically aEitherK
) givenInjectK
.Lift into
G
(typically aEitherK
) givenInjectK
. Analogous toFree.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(...)
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def map[B](f: (A) ⇒ B): Free[S, B]
-
final
def
mapK[T[_]](f: ~>[S, T]): Free[T, A]
Modify the functor context
S
using transformationf
.Modify the functor context
S
using transformationf
.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
. -
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
-
def
productIterator: Iterator[Any]
- Definition Classes
- Product
-
def
productPrefix: String
- Definition Classes
- Product
-
final
def
resume(implicit S: Functor[S]): Either[S[Free[S, A]], A]
Evaluate a single layer of the free monad.
Evaluate a single layer of the free monad.
- Annotations
- @tailrec()
-
final
def
run(implicit S: Comonad[S]): A
Run to completion, using the given comonad to extract the resumption.
-
final
def
runM[M[_]](f: (S[Free[S, A]]) ⇒ M[Free[S, A]])(implicit S: Functor[S], M: Monad[M]): M[A]
Run to completion, using a function that maps the resumption from
S
to a monadM
. -
final
def
runTailRec(implicit S: Monad[S]): S[A]
Run to completion, using monadic recursion to evaluate the resumption in the context of
S
. -
final
def
step: Free[S, A]
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.
- Definition Classes
- Free → FreeFoldStep
- Annotations
- @tailrec()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
- final def toFreeT[G[_]](implicit arg0: Applicative[G]): FreeT[S, G, A]
-
def
toString(): String
- Definition Classes
- Free → AnyRef → Any
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )