comonad-transformers-3.0.1: Comonad transformers

Portabilityportable
Stabilityprovisional
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellNone

Control.Comonad.Trans.Store

Contents

Description

The strict store (state-in-context/costate) comonad transformer is subject to the laws:

 x = seek (pos x) x
 y = pos (seek y x)
 seek y x = seek y (seek z x)

Thanks go to Russell O'Connor and Daniel Peebles for their help formulating and proving the laws for this comonad transformer.

Synopsis

The Store comonad

store :: (s -> a) -> s -> Store s aSource

runStore :: Store s a -> (s -> a, s)Source

The Store comonad transformer

data StoreT s w a Source

Constructors

StoreT (w (s -> a)) s 

Instances

ComonadTrans (StoreT s) 
ComonadHoist (StoreT s) 
Functor w => Functor (StoreT s w) 
(Typeable s, Typeable1 w) => Typeable1 (StoreT s w) 
(Functor (StoreT s w), Applicative w, Monoid s) => Applicative (StoreT s w) 
(Functor (StoreT s w), Comonad w) => Comonad (StoreT s w) 
(Comonad (StoreT s w), ComonadApply w, Semigroup s) => ComonadApply (StoreT s w) 
(Functor (StoreT s w), Apply w, Semigroup s) => Apply (StoreT s w) 
(Functor (StoreT s w), Extend w) => Extend (StoreT s w) 
(Typeable s, Typeable1 w, Typeable a) => Typeable (StoreT s w a) 

runStoreT :: StoreT s w a -> (w (s -> a), s)Source

Operations

pos :: StoreT s w a -> sSource

Read the current position

seek :: Comonad w => s -> StoreT s w a -> StoreT s w aSource

Seek to an absolute location

 seek s = peek s . duplicate

seeks :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w aSource

Seek to a relative location

 seeks f = peeks f . duplicate

peek :: Comonad w => s -> StoreT s w a -> aSource

Peek at a value at a given absolute location

 peek x . extend (peek y) = peek y

peeks :: Comonad w => (s -> s) -> StoreT s w a -> aSource

Peek at a value at a given relative location

experiment :: (Comonad w, Functor f) => (s -> f s) -> StoreT s w a -> f aSource