This module defines the Traced comonad.

#Traced Source

type Traced m = TracedT m Identity

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

#runTraced Source

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

Unwrap a value in the Traced comonad.

#traced Source

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 Source

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.


  • 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


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


#tracks Source

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 Source

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 Source

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

Get the current position.

#censor Source

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 Source

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.



#runTracedT Source

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

Unwrap a value in the TracedT comonad.