-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Comonad transformers requiring extensions to Haskell 98 -- -- Comonads and comonad transformers that require extensions to Haskell -- 98 @package comonad-extras @version 0.2 -- | The trace comonad transformer (aka the cowriter or exponential comonad -- transformer). module Control.Comonad.Traced.MemoTrie type Traced m = TracedT m Identity traced :: HasTrie m => (m -> a) -> Traced m a runTraced :: HasTrie m => Traced m a -> m -> a newtype TracedT m w a TracedT :: (w (m :->: a)) -> TracedT m w a trace :: ComonadTraced m w => forall a. m -> w a -> a listen :: (Functor w, HasTrie m) => TracedT m w a -> TracedT m w (a, m) listens :: (Functor w, HasTrie m) => (m -> b) -> TracedT m w a -> TracedT m w (a, b) censor :: (Functor w, HasTrie m) => (m -> m) -> TracedT m w a -> TracedT m w a instance (Typeable s, Typeable1 w) => Typeable1 (TracedT s w) instance (ComonadEnv e w, Semigroup m, Monoid m, HasTrie m) => ComonadEnv e (TracedT m w) instance (Comonad w, Semigroup m, Monoid m, HasTrie m) => ComonadTraced m (TracedT m w) instance (ComonadStore s w, Semigroup m, Monoid m, HasTrie m) => ComonadStore s (TracedT m w) instance (Semigroup m, Monoid m, HasTrie m) => ComonadHoist (TracedT m) instance (Semigroup m, Monoid m, HasTrie m) => ComonadTrans (TracedT m) instance (Comonad w, Semigroup m, Monoid m, HasTrie m) => Comonad (TracedT m w) instance (Extend w, Semigroup m, HasTrie m) => Extend (TracedT m w) instance (Applicative w, HasTrie m) => Applicative (TracedT m w) instance (Apply w, HasTrie m) => Apply (TracedT m w) instance (Functor w, HasTrie m) => Functor (TracedT m w) -- | The trie-memoizing 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. module Control.Comonad.Store.MemoTrie type Store s = StoreT s Identity store :: HasTrie s => (s -> a) -> s -> Store s a runStore :: HasTrie s => Store s a -> (s -> a, s) data StoreT s w a StoreT :: (w (s :->: a)) -> s -> StoreT s w a storeT :: (Functor w, HasTrie s) => w (s -> a) -> s -> StoreT s w a runStoreT :: (Functor w, HasTrie s) => StoreT s w a -> (w (s -> a), s) instance (ComonadEnv m w, HasTrie s) => ComonadEnv m (StoreT s w) instance (ComonadTraced m w, HasTrie s) => ComonadTraced m (StoreT s w) instance (Comonad w, HasTrie s) => ComonadStore s (StoreT s w) instance ComonadHoist (StoreT s) instance HasTrie s => ComonadTrans (StoreT s) instance (Comonad w, HasTrie s) => Comonad (StoreT s w) instance (Extend w, HasTrie s) => Extend (StoreT s w) instance (Applicative w, Semigroup s, Monoid s, HasTrie s) => Applicative (StoreT s w) instance (Apply w, Semigroup s, HasTrie s) => Apply (StoreT s w) instance (Functor w, HasTrie s) => Functor (StoreT s w) instance (Typeable s, Typeable1 w, Typeable a) => Typeable (StoreT s w a) instance (Typeable s, Typeable1 w) => Typeable1 (StoreT s w) -- | 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. module Control.Comonad.Store.Pointer 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 -> PointerT i w a runPointerT :: PointerT i w a -> (w (Array i a), i) -- | Extract the bounds of the currently focused array pointerBounds :: (Comonad w, Ix i) => PointerT i w a -> (i, i) instance (ComonadEnv m w, Ix i) => ComonadEnv m (PointerT i w) instance (ComonadTraced m w, Ix i) => ComonadTraced m (PointerT i w) instance (Comonad w, Ix i) => ComonadStore i (PointerT i w) instance Ix i => ComonadHoist (PointerT i) instance Ix i => ComonadTrans (PointerT i) instance (Comonad w, Ix i) => Comonad (PointerT i w) instance (Comonad w, Ix i) => Extend (PointerT i w) instance (Functor w, Ix i) => Functor (PointerT i w) instance (Typeable i, Typeable1 w, Typeable a) => Typeable (PointerT i w a) instance (Typeable i, Typeable1 w) => Typeable1 (PointerT i w) module Control.Comonad.Store.Zipper data Zipper t a zipper :: Traversable t => t a -> Maybe (Zipper t a) zipper1 :: Traversable1 t => t a -> Zipper t a unzipper :: Zipper t a -> t a size :: Zipper t a -> Int instance Comonad (Zipper t) instance Extend (Zipper t) instance Traversable (Zipper t) instance Foldable (Zipper t) instance Functor (Zipper t) instance ComonadStore Int (Zipper t)