Module

Control.Comonad.Traced.Class

Package
purescript-transformers
Repository
purescript/purescript-transformers

This module defines the ComonadTraced type class and its instances.

#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.

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 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.

#listen Source

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

Get the current position.

#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.

#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.