Cofree

sealed abstract
class Cofree[S[_], A]

A cofree comonad for some functor S, i.e. an S-branching stream.

Companion
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def applyCofree[B](f: A => B, g: Cofree[S, A] => Cofree[S, B])(implicit S: Functor[S]): Cofree[S, B]

Applies f to the head and g through the tail.

Applies f to the head and g through the tail.

def head: A
def t: Trampoline[S[Cofree[S, A]]]

Concrete methods

final
def =>>[B](f: Cofree[S, A] => B)(implicit S: Functor[S]): Cofree[S, B]

Alias for extend

Alias for extend

final
def applyTail[B](b: B, g: Cofree[S, A] => Cofree[S, B])(implicit S: Functor[S]): Cofree[S, B]

Replaces the head with b and applies g through the tail.

Replaces the head with b and applies g through the tail.

final
def copure: A

Alias for head, for compatibility with Scalaz 6

Alias for head, for compatibility with Scalaz 6

final
def duplicate(implicit S: Functor[S]): Cofree[S, Cofree[S, A]]

Redecorates the structure with values representing entire substructures.

Redecorates the structure with values representing entire substructures.

final
def extend[B](f: Cofree[S, A] => B)(implicit S: Functor[S]): Cofree[S, B]

Redecorates this structure with a computation whose context is the entire structure under that value.

Redecorates this structure with a computation whose context is the entire structure under that value.

final
def extract: A

Alias for head, for compatibility with Scalaz 6

Alias for head, for compatibility with Scalaz 6

final
def inject[B](b: B)(implicit S: Functor[S]): Cofree[S, B]

Injects a constant value into this structure.

Injects a constant value into this structure.

final
def map[B](f: A => B)(implicit S: Functor[S]): Cofree[S, B]
final
def mapBranching[T[_]](f: NaturalTransformation[S, T])(implicit S: Functor[S]): Cofree[T, A]

Changes the branching functor with the given natural transformation, using the source branching functor's fmap.

Changes the branching functor with the given natural transformation, using the source branching functor's fmap.

final
def mapBranchingT[T[_]](f: NaturalTransformation[S, T])(implicit T: Functor[T]): Cofree[T, A]

Changes the branching functor with the given natural transformation, using the target branching functor's fmap.

Changes the branching functor with the given natural transformation, using the target branching functor's fmap.

Modifies the first branching with the given natural transformation.

Modifies the first branching with the given natural transformation.

final
def out: S[Cofree[S, A]]

Alias for tail, for compatibility with Scalaz 6

Alias for tail, for compatibility with Scalaz 6

def scanr[B](g: (A, S[Cofree[S, B]]) => B)(implicit S: Functor[S]): Cofree[S, B]

Folds over this cofree structure, returning all the intermediate values in a new structure.

Folds over this cofree structure, returning all the intermediate values in a new structure.

def tail: S[Cofree[S, A]]
final
def toPair: (A, S[Cofree[S, A]])

Returns the components of this structure in a tuple.

Returns the components of this structure in a tuple.

final
def zap[G[_], B](fs: Free[G, A => B])(implicit d: Zap[S, G]): B

Applies a function in a monad to the corresponding value in this comonad, annihilating both.

Applies a function in a monad to the corresponding value in this comonad, annihilating both.

final
def zapWith[G[_], B, C](bs: Free[G, B])(f: (A, B) => C)(implicit d: Zap[S, G]): C

Applies a function f to a value in this comonad and a corresponding value in the dual monad, annihilating both.

Applies a function f to a value in this comonad and a corresponding value in the dual monad, annihilating both.