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 a m. Traced m a -> m -> a

Unwrap a value in the Traced comonad.

#traced Source

traced :: forall a m. (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 t a w. 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 b t a w. 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 t a w. Functor w => TracedT t w a -> TracedT t w (Tuple a t)

Get the current position.

#censor Source

censor :: forall t a w. 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 t a w. TracedT t w a -> w (t -> a)

Unwrap a value in the TracedT comonad.