FreeAp

sealed abstract
class FreeAp[F[_], A]

Free applicative functors. Less expressive than free monads, but more flexible to inspect and interpret.

Companion
object
class Object
trait Matchable
class Any

Value members

Concrete methods

def analyze[M : Monoid](f: NaturalTransformation[F, [α] =>> M]): M

Performs a monoidal analysis over this free program. Maps the effects in F to values in the monoid M, discarding the values of those effects. Example:

Performs a monoidal analysis over this free program. Maps the effects in F to values in the monoid M, discarding the values of those effects. Example:

def count[F[_],B](p: FreeAp[F,B]): Int =
 p.analyze(new (F ~> λ[α => Int]) {
   def apply[A](a: F[A]) = 1
 })
def ap[B](f: FreeAp[F, A => B]): FreeAp[F, B]

Idiomatic function application

Idiomatic function application

def foldMap[G[_] : Applicative](f: NaturalTransformation[F, G]): G[A]

The canonical natural transformation that interprets this free program by giving it the semantics of the applicative functor G. Not tail-recursive unless G is a free monad.

The canonical natural transformation that interprets this free program by giving it the semantics of the applicative functor G. Not tail-recursive unless G is a free monad.

def hoist[G[_]](f: NaturalTransformation[F, G]): FreeAp[G, A]

The natural transformation from FreeAp[F,_] to FreeAp[G,_]

The natural transformation from FreeAp[F,_] to FreeAp[G,_]

def map[B](f: A => B): FreeAp[F, B]

Append a function to the end of this program

Append a function to the end of this program

def monadic: Free[F, A]

Embeds this program in the free monad on F.

Embeds this program in the free monad on F.

def para[B](pure: A => B, ap: NaturalTransformation[[α] =>> (F[α], FreeAp[F, α => A]), [α] =>> B]): B

Provides access to the first instruction of this program, if present

Provides access to the first instruction of this program, if present

def retract(implicit F: Applicative[F]): F[A]

Interprets this free F program using the semantics of the Applicative instance for F.

Interprets this free F program using the semantics of the Applicative instance for F.