comonad-transformers-1.0.1: Haskell 98 comonad transformers

Portabilityportable
Stabilityprovisional
MaintainerEdward Kmett <ekmett@gmail.com>

Control.Comonad.Trans.Store.Memo.Strict

Contents

Description

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

 x = put (get x) x
 y = get (put y x)
 put y x = put y (put z x)

This version of the transformer lazily memoizes the result of applying the comonad to the current state. This can be useful for avoiding redundant computation if you reuse the same StoreT object multiple times.

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

Instances

storeT :: Functor w => w (s -> a) -> s -> StoreT s w aSource

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

Operations

get :: StoreT s w a -> sSource

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

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

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