Copyright | (c) Edward Kmett & Sjoerd Visscher 2011 |
---|---|
License | BSD3 |
Maintainer | ekmett@gmail.com |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This is a generalized
Store
Comonad
, parameterized by a
Representable
Functor
.
The representation of that
Functor
serves as the index of the store.
This can be useful if the representable functor serves to memoize its contents and will be inspected often.
Synopsis
- type Store g = StoreT g Identity
- store :: Representable g => ( Rep g -> a) -> Rep g -> Store g a
- runStore :: Representable g => Store g a -> ( Rep g -> a, Rep g)
- data StoreT g w a = StoreT (w (g a)) ( Rep g)
- storeT :: ( Functor w, Representable g) => w ( Rep g -> a) -> Rep g -> StoreT g w a
- runStoreT :: ( Functor w, Representable g) => StoreT g w a -> (w ( Rep g -> a), Rep g)
- class Comonad w => ComonadStore s (w :: Type -> Type ) | w -> s where
Documentation
type Store g = StoreT g Identity Source #
A memoized store comonad parameterized by a representable functor
g
, where
the representatation of
g
,
Rep g
is the index of the store.
:: Representable g | |
=> ( Rep g -> a) |
computation |
-> Rep g |
index |
-> Store g a |
Construct a store comonad computation from a function and a current index.
(The inverse of
runStore
.)
:: Representable g | |
=> Store g a |
a store to access |
-> ( Rep g -> a, Rep g) |
initial state |
Unwrap a store comonad computation as a function and a current index.
(The inverse of
store
.)
A store transformer comonad parameterized by:
-
g
- A representable functor used to memoize results for an indexRep g
-
w
- The inner comonad.
Instances
class Comonad w => ComonadStore s (w :: Type -> Type ) | w -> s where Source #
peek :: s -> w a -> a Source #
peeks :: (s -> s) -> w a -> a Source #
seek :: s -> w a -> w a Source #
seeks :: (s -> s) -> w a -> w a Source #
experiment :: Functor f => (s -> f s) -> w a -> f a Source #