Module

Control.Comonad.Traced

This module defines the Traced comonad.

#Traced

type Traced m = TracedT m Identity

The Traced comonad is a synonym for the TracedT comonad transformer, applied to the Identity monad.

#runTraced

runTraced :: forall m a. Traced m a -> m -> a

Unwrap a value in the Traced comonad.

#traced

traced :: forall m a. (m -> a) -> Traced m a

Create a value in context in the Traced comonad.

Re-exports from Control.Comonad.Traced.Class

#ComonadTraced

class (Comonad w) <= ComonadTraced t w | w -> t where

The ComonadTraced type class represents those monads which support relative (monoidal) position information via track.

  • track extracts a value at the specified relative position.

An implementation is provided for TracedT.

Laws:

  • track mempty = extract
  • (track s =<= track t) x = track (s <> t) x

For example:

blur :: forall w. (ComonadTraced (Additive Number) w) -> w Number -> w Number
blur = extend \r -> (track (Additive (-1)) r + track (Additive 1) r) / 2

Members

  • track :: forall a. t -> w a -> a

Instances

#tracks

tracks :: forall w a t. ComonadTraced t w => (a -> t) -> w a -> a

Extracts a value at a relative position which depends on the current value.

#listens

listens :: forall w a t b. Functor w => (t -> b) -> TracedT t w a -> TracedT t w (Tuple a b)

Get a value which depends on the current position.

#listen

listen :: forall w a t. Functor w => TracedT t w a -> TracedT t w (Tuple a t)

Get the current position.

#censor

censor :: forall w a t. Functor w => (t -> t) -> TracedT t w a -> TracedT t w a

Apply a function to the current position.

Re-exports from Control.Comonad.Traced.Trans

#TracedT

newtype TracedT t w a

The cowriter comonad transformer.

This comonad transformer extends the context of a value in the base comonad so that the value depends on a monoidal position of type t.

The ComonadTraced type class describes the operations supported by this comonad.

Constructors

Instances

#runTracedT

runTracedT :: forall w a t. TracedT t w a -> w (t -> a)

Unwrap a value in the TracedT comonad.

Modules