Listen

cats.mtl.Listen
See theListen companion object
trait Listen[F[_], L] extends Tell[F, L], Serializable

Listen[F, L] is a function F[A] => F[(A, L)] which exposes some state that is contained in all F[A] values, and can be modified using tell.

Listen has two external laws:

def listenRespectsTell(l: L) = {
 listen(tell(l)) <-> tell(l).as(((), l))
}

def listenAddsNoEffects(fa: F[A]) = {
 listen(fa).map(_._1) <-> fa
}

Listen has one internal law:

def listensIsListenThenMap(fa: F[A], f: L => B) = {
 listens(fa)(f) <-> listen(fa).map { case (a, l) => (a, f(l)) }
}

Attributes

Companion
object
Source
Listen.scala
Graph
Supertypes
trait Tell[F, L]
trait Serializable
class Object
trait Matchable
class Any
Known subtypes
trait Censor[F, L]

Members list

Value members

Abstract methods

def listen[A](fa: F[A]): F[(A, L)]

Attributes

Source
Listen.scala

Concrete methods

def listens[A, B](fa: F[A])(f: L => B): F[(A, B)]

Attributes

Source
Listen.scala

Inherited methods

def functor: Functor[F]

Attributes

Inherited from:
Tell
Source
Tell.scala
def tell(l: L): F[Unit]

Attributes

Inherited from:
Tell
Source
Tell.scala
def tuple[A](ta: (L, A)): F[A]

Attributes

Inherited from:
Tell
Source
Tell.scala
def writer[A](a: A, l: L): F[A]

Attributes

Inherited from:
Tell
Source
Tell.scala