Copyright | (C) 2008-2015 Edward Kmett |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | provisional |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell98 |
The array-backed 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.
This basic version of this transformer first appeared on Dan Piponi's blog at http://blog.sigfpe.com/2008/03/comonadic-arrays.html.
Since this module relies on the non-Haskell 98 arrays
package, it is
located here instead of in comonad-transformers.
NB: attempting to seek or peek out of bounds will yield an error.
Synopsis
- type Pointer i = PointerT i Identity
- pointer :: Array i a -> i -> Pointer i a
- runPointer :: Pointer i a -> (Array i a, i)
- data PointerT i w a = PointerT (w (Array i a)) i
- runPointerT :: PointerT i w a -> (w (Array i a), i)
- pointerBounds :: (Comonad w, Ix i) => PointerT i w a -> (i, i)
- module Control.Comonad.Store.Class
The Pointer comonad
runPointer :: Pointer i a -> (Array i a, i) Source #
The Pointer comonad transformer
Instances
(ComonadEnv m w, Ix i) => ComonadEnv m (PointerT i w) Source # | |
Defined in Control.Comonad.Store.Pointer | |
(Comonad w, Ix i) => ComonadStore i (PointerT i w) Source # | |
Defined in Control.Comonad.Store.Pointer | |
(ComonadTraced m w, Ix i) => ComonadTraced m (PointerT i w) Source # | |
Defined in Control.Comonad.Store.Pointer | |
Ix i => ComonadTrans (PointerT i) Source # | |
Defined in Control.Comonad.Store.Pointer | |
Ix i => ComonadHoist (PointerT i) Source # | |
(Functor w, Ix i) => Functor (PointerT i w) Source # | |
(Comonad w, Ix i) => Comonad (PointerT i w) Source # | |
(Comonad w, Ix i) => Extend (PointerT i w) Source # | |
runPointerT :: PointerT i w a -> (w (Array i a), i) Source #
pointerBounds :: (Comonad w, Ix i) => PointerT i w a -> (i, i) Source #
Extract the bounds of the currently focused array
module Control.Comonad.Store.Class