comonad-transformers 2.0.3 → 2.1
raw patch · 15 files changed
+252/−1041 lines, 15 filesdep ~comonaddep ~contravariantdep ~distributivePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: comonad, contravariant, distributive, semigroupoids, semigroups, transformers
API changes (from Hackage documentation)
- Control.Comonad.Trans.Discont.Lazy: DiscontT :: (w s -> a) -> (w s) -> DiscontT s w a
- Control.Comonad.Trans.Discont.Lazy: data DiscontT s w a
- Control.Comonad.Trans.Discont.Lazy: discont :: (s -> a) -> s -> Discont s a
- Control.Comonad.Trans.Discont.Lazy: instance (Typeable s, Typeable1 w) => Typeable1 (DiscontT s w)
- Control.Comonad.Trans.Discont.Lazy: instance Comonad (DiscontT s w)
- Control.Comonad.Trans.Discont.Lazy: instance ComonadTrans (DiscontT s)
- Control.Comonad.Trans.Discont.Lazy: instance Extend (DiscontT s w)
- Control.Comonad.Trans.Discont.Lazy: instance Functor (DiscontT s w)
- Control.Comonad.Trans.Discont.Lazy: runDiscont :: Discont s a -> (s -> a, s)
- Control.Comonad.Trans.Discont.Lazy: runDiscontT :: DiscontT s w a -> (w s -> a, w s)
- Control.Comonad.Trans.Discont.Lazy: type Discont s = DiscontT s Identity
- Control.Comonad.Trans.Discont.Memo: data DiscontT s w a
- Control.Comonad.Trans.Discont.Memo: discont :: (s -> a) -> s -> Discont s a
- Control.Comonad.Trans.Discont.Memo: discontT :: (w s -> a) -> w s -> DiscontT s w a
- Control.Comonad.Trans.Discont.Memo: instance (Typeable s, Typeable1 w) => Typeable1 (DiscontT s w)
- Control.Comonad.Trans.Discont.Memo: instance Comonad (DiscontT s w)
- Control.Comonad.Trans.Discont.Memo: instance ComonadTrans (DiscontT s)
- Control.Comonad.Trans.Discont.Memo: instance Extend (DiscontT s w)
- Control.Comonad.Trans.Discont.Memo: instance Functor (DiscontT s w)
- Control.Comonad.Trans.Discont.Memo: runDiscont :: Discont s a -> (s -> a, s)
- Control.Comonad.Trans.Discont.Memo: runDiscontT :: DiscontT s w a -> (w s -> a, w s)
- Control.Comonad.Trans.Discont.Memo: type Discont s = DiscontT s Identity
- Control.Comonad.Trans.Discont.Strict: DiscontT :: (w s -> a) -> (w s) -> DiscontT s w a
- Control.Comonad.Trans.Discont.Strict: data DiscontT s w a
- Control.Comonad.Trans.Discont.Strict: discont :: (s -> a) -> s -> Discont s a
- Control.Comonad.Trans.Discont.Strict: instance (Typeable s, Typeable1 w) => Typeable1 (DiscontT s w)
- Control.Comonad.Trans.Discont.Strict: instance Comonad (DiscontT s w)
- Control.Comonad.Trans.Discont.Strict: instance ComonadTrans (DiscontT s)
- Control.Comonad.Trans.Discont.Strict: instance Extend (DiscontT s w)
- Control.Comonad.Trans.Discont.Strict: instance Functor (DiscontT s w)
- Control.Comonad.Trans.Discont.Strict: runDiscont :: Discont s a -> (s -> a, s)
- Control.Comonad.Trans.Discont.Strict: runDiscontT :: DiscontT s w a -> (w s -> a, w s)
- Control.Comonad.Trans.Discont.Strict: type Discont s = DiscontT s Identity
- Control.Comonad.Trans.Env.Lazy: EnvT :: e -> (w a) -> EnvT e w a
- Control.Comonad.Trans.Env.Lazy: ask :: EnvT e w a -> e
- Control.Comonad.Trans.Env.Lazy: asks :: (e -> f) -> EnvT e w a -> f
- Control.Comonad.Trans.Env.Lazy: data EnvT e w a
- Control.Comonad.Trans.Env.Lazy: env :: e -> a -> Env e a
- Control.Comonad.Trans.Env.Lazy: instance (Data e, Typeable1 w, Data (w a), Data a) => Data (EnvT e w a)
- Control.Comonad.Trans.Env.Lazy: instance (Semigroup e, Apply w) => Apply (EnvT e w)
- Control.Comonad.Trans.Env.Lazy: instance (Typeable s, Typeable1 w) => Typeable1 (EnvT s w)
- Control.Comonad.Trans.Env.Lazy: instance (Typeable s, Typeable1 w, Typeable a) => Typeable (EnvT s w a)
- Control.Comonad.Trans.Env.Lazy: instance Comonad w => Comonad (EnvT e w)
- Control.Comonad.Trans.Env.Lazy: instance ComonadHoist (EnvT e)
- Control.Comonad.Trans.Env.Lazy: instance ComonadTrans (EnvT e)
- Control.Comonad.Trans.Env.Lazy: instance Extend w => Extend (EnvT e w)
- Control.Comonad.Trans.Env.Lazy: instance Foldable w => Foldable (EnvT e w)
- Control.Comonad.Trans.Env.Lazy: instance Functor w => Functor (EnvT e w)
- Control.Comonad.Trans.Env.Lazy: instance Traversable w => Traversable (EnvT e w)
- Control.Comonad.Trans.Env.Lazy: local :: (e -> e) -> EnvT e w a -> EnvT e w a
- Control.Comonad.Trans.Env.Lazy: lowerEnvT :: EnvT e w a -> w a
- Control.Comonad.Trans.Env.Lazy: runEnv :: Env e a -> (e, a)
- Control.Comonad.Trans.Env.Lazy: runEnvT :: EnvT e w a -> (e, w a)
- Control.Comonad.Trans.Env.Lazy: type Env e = EnvT e Identity
- Control.Comonad.Trans.Env.Strict: EnvT :: e -> (w a) -> EnvT e w a
- Control.Comonad.Trans.Env.Strict: ask :: EnvT e w a -> e
- Control.Comonad.Trans.Env.Strict: asks :: (e -> f) -> EnvT e w a -> f
- Control.Comonad.Trans.Env.Strict: data EnvT e w a
- Control.Comonad.Trans.Env.Strict: env :: e -> a -> Env e a
- Control.Comonad.Trans.Env.Strict: instance (Data e, Typeable1 w, Data (w a), Data a) => Data (EnvT e w a)
- Control.Comonad.Trans.Env.Strict: instance (Semigroup e, Apply w) => Apply (EnvT e w)
- Control.Comonad.Trans.Env.Strict: instance (Typeable s, Typeable1 w) => Typeable1 (EnvT s w)
- Control.Comonad.Trans.Env.Strict: instance (Typeable s, Typeable1 w, Typeable a) => Typeable (EnvT s w a)
- Control.Comonad.Trans.Env.Strict: instance Comonad w => Comonad (EnvT e w)
- Control.Comonad.Trans.Env.Strict: instance ComonadHoist (EnvT e)
- Control.Comonad.Trans.Env.Strict: instance ComonadTrans (EnvT e)
- Control.Comonad.Trans.Env.Strict: instance Extend w => Extend (EnvT e w)
- Control.Comonad.Trans.Env.Strict: instance Foldable w => Foldable (EnvT e w)
- Control.Comonad.Trans.Env.Strict: instance Functor w => Functor (EnvT e w)
- Control.Comonad.Trans.Env.Strict: instance Traversable w => Traversable (EnvT e w)
- Control.Comonad.Trans.Env.Strict: local :: (e -> e) -> EnvT e w a -> EnvT e w a
- Control.Comonad.Trans.Env.Strict: lowerEnvT :: EnvT e w a -> w a
- Control.Comonad.Trans.Env.Strict: runEnv :: Env e a -> (e, a)
- Control.Comonad.Trans.Env.Strict: runEnvT :: EnvT e w a -> (e, w a)
- Control.Comonad.Trans.Env.Strict: type Env e = EnvT e Identity
- Control.Comonad.Trans.Store.Lazy: StoreT :: (w (s -> a)) -> s -> StoreT s w a
- Control.Comonad.Trans.Store.Lazy: data StoreT s w a
- Control.Comonad.Trans.Store.Lazy: instance (Applicative w, Semigroup s, Monoid s) => Applicative (StoreT s w)
- Control.Comonad.Trans.Store.Lazy: instance (Apply w, Semigroup s) => Apply (StoreT s w)
- Control.Comonad.Trans.Store.Lazy: instance (Typeable s, Typeable1 w) => Typeable1 (StoreT s w)
- Control.Comonad.Trans.Store.Lazy: instance (Typeable s, Typeable1 w, Typeable a) => Typeable (StoreT s w a)
- Control.Comonad.Trans.Store.Lazy: instance Comonad w => Comonad (StoreT s w)
- Control.Comonad.Trans.Store.Lazy: instance ComonadHoist (StoreT s)
- Control.Comonad.Trans.Store.Lazy: instance ComonadTrans (StoreT s)
- Control.Comonad.Trans.Store.Lazy: instance Extend w => Extend (StoreT s w)
- Control.Comonad.Trans.Store.Lazy: instance Functor w => Functor (StoreT s w)
- Control.Comonad.Trans.Store.Lazy: peek :: Comonad w => s -> StoreT s w a -> a
- Control.Comonad.Trans.Store.Lazy: peeks :: Comonad w => (s -> s) -> StoreT s w a -> a
- Control.Comonad.Trans.Store.Lazy: pos :: StoreT s w a -> s
- Control.Comonad.Trans.Store.Lazy: runStore :: Store s a -> (s -> a, s)
- Control.Comonad.Trans.Store.Lazy: runStoreT :: StoreT s w a -> (w (s -> a), s)
- Control.Comonad.Trans.Store.Lazy: seek :: Comonad w => s -> StoreT s w a -> StoreT s w a
- Control.Comonad.Trans.Store.Lazy: seeks :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a
- Control.Comonad.Trans.Store.Lazy: store :: (s -> a) -> s -> Store s a
- Control.Comonad.Trans.Store.Lazy: type Store s = StoreT s Identity
- Control.Comonad.Trans.Store.Memo: data StoreT s w a
- Control.Comonad.Trans.Store.Memo: instance (Applicative w, Semigroup s, Monoid s) => Applicative (StoreT s w)
- Control.Comonad.Trans.Store.Memo: instance (Apply w, Semigroup s) => Apply (StoreT s w)
- Control.Comonad.Trans.Store.Memo: instance (Typeable s, Typeable1 w) => Typeable1 (StoreT s w)
- Control.Comonad.Trans.Store.Memo: instance (Typeable s, Typeable1 w, Typeable a) => Typeable (StoreT s w a)
- Control.Comonad.Trans.Store.Memo: instance Comonad w => Comonad (StoreT s w)
- Control.Comonad.Trans.Store.Memo: instance ComonadHoist (StoreT s)
- Control.Comonad.Trans.Store.Memo: instance ComonadTrans (StoreT s)
- Control.Comonad.Trans.Store.Memo: instance Extend w => Extend (StoreT s w)
- Control.Comonad.Trans.Store.Memo: instance Functor w => Functor (StoreT s w)
- Control.Comonad.Trans.Store.Memo: lowerStoreT :: StoreT s w a -> w a
- Control.Comonad.Trans.Store.Memo: peek :: Comonad w => s -> StoreT s w a -> a
- Control.Comonad.Trans.Store.Memo: peeks :: Comonad w => (s -> s) -> StoreT s w a -> a
- Control.Comonad.Trans.Store.Memo: pos :: StoreT s w a -> s
- Control.Comonad.Trans.Store.Memo: runStore :: Store s a -> (s -> a, s)
- Control.Comonad.Trans.Store.Memo: runStoreT :: StoreT s w a -> (w (s -> a), s)
- Control.Comonad.Trans.Store.Memo: seek :: Comonad w => s -> StoreT s w a -> StoreT s w a
- Control.Comonad.Trans.Store.Memo: seeks :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a
- Control.Comonad.Trans.Store.Memo: store :: (s -> a) -> s -> Store s a
- Control.Comonad.Trans.Store.Memo: storeT :: Functor w => w (s -> a) -> s -> StoreT s w a
- Control.Comonad.Trans.Store.Memo: type Store s = StoreT s Identity
- Control.Comonad.Trans.Store.Strict: StoreT :: (w (s -> a)) -> s -> StoreT s w a
- Control.Comonad.Trans.Store.Strict: data StoreT s w a
- Control.Comonad.Trans.Store.Strict: instance (Applicative w, Semigroup s, Monoid s) => Applicative (StoreT s w)
- Control.Comonad.Trans.Store.Strict: instance (Apply w, Semigroup s) => Apply (StoreT s w)
- Control.Comonad.Trans.Store.Strict: instance (Typeable s, Typeable1 w) => Typeable1 (StoreT s w)
- Control.Comonad.Trans.Store.Strict: instance (Typeable s, Typeable1 w, Typeable a) => Typeable (StoreT s w a)
- Control.Comonad.Trans.Store.Strict: instance Comonad w => Comonad (StoreT s w)
- Control.Comonad.Trans.Store.Strict: instance ComonadHoist (StoreT s)
- Control.Comonad.Trans.Store.Strict: instance ComonadTrans (StoreT s)
- Control.Comonad.Trans.Store.Strict: instance Extend w => Extend (StoreT s w)
- Control.Comonad.Trans.Store.Strict: instance Functor w => Functor (StoreT s w)
- Control.Comonad.Trans.Store.Strict: peek :: Comonad w => s -> StoreT s w a -> a
- Control.Comonad.Trans.Store.Strict: peeks :: Comonad w => (s -> s) -> StoreT s w a -> a
- Control.Comonad.Trans.Store.Strict: pos :: StoreT s w a -> s
- Control.Comonad.Trans.Store.Strict: runStore :: Store s a -> (s -> a, s)
- Control.Comonad.Trans.Store.Strict: runStoreT :: StoreT s w a -> (w (s -> a), s)
- Control.Comonad.Trans.Store.Strict: seek :: Comonad w => s -> StoreT s w a -> StoreT s w a
- Control.Comonad.Trans.Store.Strict: seeks :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a
- Control.Comonad.Trans.Store.Strict: store :: (s -> a) -> s -> Store s a
- Control.Comonad.Trans.Store.Strict: type Store s = StoreT s Identity
- Control.Comonad.Trans.Traced.Memo: censor :: (Functor w, Monoid m) => (m -> m) -> TracedT m w a -> TracedT m w a
- Control.Comonad.Trans.Traced.Memo: data TracedT m w a
- Control.Comonad.Trans.Traced.Memo: instance (Comonad w, Monoid m) => Comonad (TracedT m w)
- Control.Comonad.Trans.Traced.Memo: instance (Extend w, Monoid m) => Extend (TracedT m w)
- Control.Comonad.Trans.Traced.Memo: instance (Typeable s, Typeable1 w) => Typeable1 (TracedT s w)
- Control.Comonad.Trans.Traced.Memo: instance Applicative w => Applicative (TracedT m w)
- Control.Comonad.Trans.Traced.Memo: instance Apply w => Apply (TracedT m w)
- Control.Comonad.Trans.Traced.Memo: instance ComonadHoist (TracedT m)
- Control.Comonad.Trans.Traced.Memo: instance ComonadTrans (TracedT m)
- Control.Comonad.Trans.Traced.Memo: instance Functor w => Functor (TracedT m w)
- Control.Comonad.Trans.Traced.Memo: listen :: (Functor w, Monoid m) => TracedT m w a -> TracedT m w (a, m)
- Control.Comonad.Trans.Traced.Memo: listens :: (Functor w, Monoid m) => (m -> b) -> TracedT m w a -> TracedT m w (a, b)
- Control.Comonad.Trans.Traced.Memo: runTraced :: Traced m a -> m -> a
- Control.Comonad.Trans.Traced.Memo: runTracedT :: TracedT m w a -> w (m -> a)
- Control.Comonad.Trans.Traced.Memo: trace :: (Comonad w, Monoid m) => m -> TracedT m w a -> a
- Control.Comonad.Trans.Traced.Memo: traced :: Monoid m => (m -> a) -> Traced m a
- Control.Comonad.Trans.Traced.Memo: tracedT :: (Functor w, Monoid m) => w (m -> a) -> TracedT m w a
- Control.Comonad.Trans.Traced.Memo: type Traced m = TracedT m Identity
+ Control.Comonad.Trans.Env: EnvT :: e -> (w a) -> EnvT e w a
+ Control.Comonad.Trans.Env: ask :: EnvT e w a -> e
+ Control.Comonad.Trans.Env: asks :: (e -> f) -> EnvT e w a -> f
+ Control.Comonad.Trans.Env: data EnvT e w a
+ Control.Comonad.Trans.Env: env :: e -> a -> Env e a
+ Control.Comonad.Trans.Env: instance (Data e, Typeable1 w, Data (w a), Data a) => Data (EnvT e w a)
+ Control.Comonad.Trans.Env: instance (Semigroup e, Apply w) => Apply (EnvT e w)
+ Control.Comonad.Trans.Env: instance (Typeable s, Typeable1 w) => Typeable1 (EnvT s w)
+ Control.Comonad.Trans.Env: instance (Typeable s, Typeable1 w, Typeable a) => Typeable (EnvT s w a)
+ Control.Comonad.Trans.Env: instance Comonad w => Comonad (EnvT e w)
+ Control.Comonad.Trans.Env: instance ComonadHoist (EnvT e)
+ Control.Comonad.Trans.Env: instance ComonadTrans (EnvT e)
+ Control.Comonad.Trans.Env: instance Extend w => Extend (EnvT e w)
+ Control.Comonad.Trans.Env: instance Foldable w => Foldable (EnvT e w)
+ Control.Comonad.Trans.Env: instance Functor w => Functor (EnvT e w)
+ Control.Comonad.Trans.Env: instance Traversable w => Traversable (EnvT e w)
+ Control.Comonad.Trans.Env: local :: (e -> e) -> EnvT e w a -> EnvT e w a
+ Control.Comonad.Trans.Env: lowerEnvT :: EnvT e w a -> w a
+ Control.Comonad.Trans.Env: runEnv :: Env e a -> (e, a)
+ Control.Comonad.Trans.Env: runEnvT :: EnvT e w a -> (e, w a)
+ Control.Comonad.Trans.Env: type Env e = EnvT e Identity
+ Control.Comonad.Trans.Store: StoreT :: (w (s -> a)) -> s -> StoreT s w a
+ Control.Comonad.Trans.Store: data StoreT s w a
+ Control.Comonad.Trans.Store: instance (Applicative w, Semigroup s, Monoid s) => Applicative (StoreT s w)
+ Control.Comonad.Trans.Store: instance (Apply w, Semigroup s) => Apply (StoreT s w)
+ Control.Comonad.Trans.Store: instance (Typeable s, Typeable1 w) => Typeable1 (StoreT s w)
+ Control.Comonad.Trans.Store: instance (Typeable s, Typeable1 w, Typeable a) => Typeable (StoreT s w a)
+ Control.Comonad.Trans.Store: instance Comonad w => Comonad (StoreT s w)
+ Control.Comonad.Trans.Store: instance ComonadHoist (StoreT s)
+ Control.Comonad.Trans.Store: instance ComonadTrans (StoreT s)
+ Control.Comonad.Trans.Store: instance Extend w => Extend (StoreT s w)
+ Control.Comonad.Trans.Store: instance Functor w => Functor (StoreT s w)
+ Control.Comonad.Trans.Store: peek :: Comonad w => s -> StoreT s w a -> a
+ Control.Comonad.Trans.Store: peeks :: Comonad w => (s -> s) -> StoreT s w a -> a
+ Control.Comonad.Trans.Store: pos :: StoreT s w a -> s
+ Control.Comonad.Trans.Store: runStore :: Store s a -> (s -> a, s)
+ Control.Comonad.Trans.Store: runStoreT :: StoreT s w a -> (w (s -> a), s)
+ Control.Comonad.Trans.Store: seek :: Comonad w => s -> StoreT s w a -> StoreT s w a
+ Control.Comonad.Trans.Store: seeks :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a
+ Control.Comonad.Trans.Store: store :: (s -> a) -> s -> Store s a
+ Control.Comonad.Trans.Store: type Store s = StoreT s Identity
Files
- CHANGELOG +4/−0
- Control/Comonad/Trans/Discont.hs +0/−20
- Control/Comonad/Trans/Discont/Lazy.hs +0/−78
- Control/Comonad/Trans/Discont/Memo.hs +0/−85
- Control/Comonad/Trans/Discont/Strict.hs +0/−75
- Control/Comonad/Trans/Env.hs +119/−5
- Control/Comonad/Trans/Env/Lazy.hs +0/−136
- Control/Comonad/Trans/Env/Strict.hs +0/−130
- Control/Comonad/Trans/Store.hs +110/−6
- Control/Comonad/Trans/Store/Lazy.hs +0/−119
- Control/Comonad/Trans/Store/Memo.hs +0/−131
- Control/Comonad/Trans/Store/Strict.hs +0/−120
- Control/Comonad/Trans/Traced.hs +8/−5
- Control/Comonad/Trans/Traced/Memo.hs +0/−109
- comonad-transformers.cabal +11/−22
+ CHANGELOG view
@@ -0,0 +1,4 @@+2.1:+ * Removed Discont+ * Switched to mkTyCon3+ * Upgraded to transformers 0.3
− Control/Comonad/Trans/Discont.hs
@@ -1,20 +0,0 @@--------------------------------------------------------------------------------- |--- Module : Control.Comonad.Trans.Discont--- Copyright : (C) 2008-2011 Edward Kmett--- License : BSD-style (see the file LICENSE)------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable------ The discontinuation comonad transformer.--- This version is lazy; for a strict version, see--- "Control.Comonad.Trans.Discont.Strict", which has the same interface.---------------------------------------------------------------------------------module Control.Comonad.Trans.Discont- ( module Control.Comonad.Trans.Discont.Lazy- ) where--import Control.Comonad.Trans.Discont.Lazy
− Control/Comonad/Trans/Discont/Lazy.hs
@@ -1,78 +0,0 @@-{-# LANGUAGE RankNTypes #-}--------------------------------------------------------------------------------- |--- Module : Control.Comonad.Trans.Discont.Lazy--- Copyright : (C) 2008-2011 Edward Kmett--- License : BSD-style (see the file LICENSE)------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable--- --- 'Discont' is the density comonad of a constant functor, just as 'Cont' is a --- Codensity monad of a constant functor. (For the definition of Density and--- Codensity, see the non-Haskell 98 'adjunctions' package)------ Note that while 'Discont' and 'Store' are isomorphic, 'DiscontT' and 'StoreT' --- are not.---------------------------------------------------------------------------------module Control.Comonad.Trans.Discont.Lazy- ( - -- * The 'discontinuation' comonad- Discont- , discont- -- * The discontinuation comonad transformer- , runDiscont- , DiscontT(..)- , runDiscontT- ) where--import Data.Functor.Identity-import Control.Comonad-import Control.Comonad.Trans.Class--#ifdef __GLASGOW_HASKELL__-import Data.Typeable--instance (Typeable s, Typeable1 w) => Typeable1 (DiscontT s w) where- typeOf1 dswa = mkTyConApp discontTTyCon [typeOf (s dswa), typeOf1 (w dswa)]- where - s :: DiscontT s w a -> s- s = undefined- w :: DiscontT s w a -> w a- w = undefined--discontTTyCon :: TyCon-discontTTyCon = mkTyCon "Control.Comonad.Trans.Discont.Lazy.DiscontT" -{-# NOINLINE discontTTyCon #-}--#endif--type Discont s = DiscontT s Identity--data DiscontT s w a = DiscontT (w s -> a) (w s)--discont :: (s -> a) -> s -> Discont s a -discont f s = DiscontT (f . runIdentity) (Identity s)--runDiscont :: Discont s a -> (s -> a, s) -runDiscont ~(DiscontT f (Identity s)) = (f . Identity, s)--runDiscontT :: DiscontT s w a -> (w s -> a, w s)-runDiscontT ~(DiscontT f s) = (f, s)--instance Functor (DiscontT s w) where- fmap g ~(DiscontT f ws) = DiscontT (g . f) ws--instance Extend (DiscontT s w) where- duplicate ~(DiscontT f ws) = DiscontT (DiscontT f) ws--instance Comonad (DiscontT s w) where- extract ~(DiscontT f ws) = f ws--instance ComonadTrans (DiscontT s) where- lower ~(DiscontT f s) = extend f s---- instance Apply w => Apply (DiscontT s w) where-
− Control/Comonad/Trans/Discont/Memo.hs
@@ -1,85 +0,0 @@-{-# LANGUAGE CPP, RankNTypes #-}--------------------------------------------------------------------------------- |--- Module : Control.Comonad.Trans.Discont.Memo--- Copyright : (C) 2008-2011 Edward Kmett--- License : BSD-style (see the file LICENSE)------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable--- ------ 'Discont' is the density comonad of a constant functor, just as 'Cont' is a --- Codensity monad of a constant functor. (For the definition of Density and--- Codensity, see the non-Haskell 98 'adjunctions' package)------ Note that while 'Discont' and 'Store' are isomorphic, 'DiscontT' and 'StoreT' --- are not.------ Like the memoizing store comonad, version memoizes the result of applying --- the continuation to the current context. ---------------------------------------------------------------------------------module Control.Comonad.Trans.Discont.Memo- ( - -- * The 'discontinuation' comonad- Discont- , discont- -- * The discontinuation comonad transformer- , runDiscont- , DiscontT- , discontT - , runDiscontT- ) where--import Data.Functor.Identity-import Control.Comonad-import Control.Comonad.Trans.Class--#ifdef __GLASGOW_HASKELL__-import Data.Typeable--instance (Typeable s, Typeable1 w) => Typeable1 (DiscontT s w) where- typeOf1 dswa = mkTyConApp discontTTyCon [typeOf (s dswa), typeOf1 (w dswa)]- where - s :: DiscontT s w a -> s- s = undefined- w :: DiscontT s w a -> w a- w = undefined--discontTTyCon :: TyCon-discontTTyCon = mkTyCon "Control.Comonad.Trans.Discont.Memo.DiscontT" -{-# NOINLINE discontTTyCon #-}--#endif--type Discont s = DiscontT s Identity--data DiscontT s w a = DiscontT (w s -> a) (w s) a--discont :: (s -> a) -> s -> Discont s a -discont f s = DiscontT (f . runIdentity) (Identity s) (f s)--discontT :: (w s -> a) -> w s -> DiscontT s w a -discontT f s = DiscontT f s (f s)--runDiscont :: Discont s a -> (s -> a, s) -runDiscont (DiscontT f (Identity s) _) = (f . Identity, s)--runDiscontT :: DiscontT s w a -> (w s -> a, w s)-runDiscontT (DiscontT f s _) = (f, s)--instance Functor (DiscontT s w) where- fmap g (DiscontT f ws a) = DiscontT (g . f) ws (g a)--instance Extend (DiscontT s w) where- duplicate (DiscontT f ws _) = discontT (discontT f) ws--instance Comonad (DiscontT s w) where- extract (DiscontT _ _ a) = a--instance ComonadTrans (DiscontT s) where- lower (DiscontT f s _) = extend f s---- instance Apply w => Apply (DiscontT s w) where
− Control/Comonad/Trans/Discont/Strict.hs
@@ -1,75 +0,0 @@-{-# LANGUAGE RankNTypes #-}--------------------------------------------------------------------------------- |--- Module : Control.Comonad.Trans.Discont.Strict--- Copyright : (C) 2008-2011 Edward Kmett--- License : BSD-style (see the file LICENSE)------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable------ 'Discont' is the density comonad of a constant functor, just as 'Cont' is a --- Codensity monad of a constant functor. (For the definition of Density and--- Codensity, see the non-Haskell 98 'adjunctions' package)------ Note that while 'Discont' and 'Store' are isomorphic, 'DiscontT' and 'StoreT' --- are not.------------------------------------------------------------------------------module Control.Comonad.Trans.Discont.Strict- ( - -- * The 'discontinuation' comonad- Discont- , discont- -- * The discontinuation comonad transformer- , runDiscont- , DiscontT(..)- , runDiscontT- ) where--import Data.Functor.Identity-import Control.Comonad-import Control.Comonad.Trans.Class--#ifdef __GLASGOW_HASKELL__-import Data.Typeable--instance (Typeable s, Typeable1 w) => Typeable1 (DiscontT s w) where- typeOf1 dswa = mkTyConApp discontTTyCon [typeOf (s dswa), typeOf1 (w dswa)]- where - s :: DiscontT s w a -> s- s = undefined- w :: DiscontT s w a -> w a - w = undefined--discontTTyCon :: TyCon-discontTTyCon = mkTyCon "Control.Comonad.Trans.Discont.Strict.DiscontT" -{-# NOINLINE discontTTyCon #-}-#endif--type Discont s = DiscontT s Identity--data DiscontT s w a = DiscontT (w s -> a) (w s)--discont :: (s -> a) -> s -> Discont s a -discont f s = DiscontT (f . runIdentity) (Identity s)--runDiscont :: Discont s a -> (s -> a, s) -runDiscont (DiscontT f (Identity s)) = (f . Identity, s)--runDiscontT :: DiscontT s w a -> (w s -> a, w s)-runDiscontT (DiscontT f s) = (f, s)--instance Functor (DiscontT s w) where- fmap g (DiscontT f ws) = DiscontT (g . f) ws--instance Extend (DiscontT s w) where- duplicate (DiscontT f ws) = DiscontT (DiscontT f) ws- extend g (DiscontT f ws) = DiscontT (g . DiscontT f) ws--instance Comonad (DiscontT s w) where- extract (DiscontT f ws) = f ws--instance ComonadTrans (DiscontT s) where- lower (DiscontT f s) = extend f s-
Control/Comonad/Trans/Env.hs view
@@ -1,6 +1,7 @@+{-# LANGUAGE CPP, FlexibleContexts #-} ----------------------------------------------------------------------------- -- |--- Module : Control.Comonad.Trans.Context+-- Module : Control.Comonad.Trans.Env -- Copyright : (C) 2008-2011 Edward Kmett -- License : BSD-style (see the file LICENSE) --@@ -9,12 +10,125 @@ -- Portability : portable -- -- The environment comonad transformer (aka coreader).--- This version is lazy; for a strict version, see--- "Control.Comonad.Trans.Env.Strict", which has the same interface.+-- This adds an extra value that can be accessed in the environment. --+-- Left adjoint to the reader comonad. ---------------------------------------------------------------------------- module Control.Comonad.Trans.Env- ( module Control.Comonad.Trans.Env.Lazy+ (+ -- * The strict environment comonad+ Env+ , env+ , runEnv+ -- * The strict environment comonad transformer+ , EnvT(..)+ , runEnvT+ , lowerEnvT+ -- * Combinators+ , ask+ , asks+ , local ) where -import Control.Comonad.Trans.Env.Lazy+import Control.Comonad+import Control.Comonad.Hoist.Class+import Control.Comonad.Trans.Class+import Data.Foldable+import Data.Traversable+import Data.Functor.Apply+import Data.Functor.Identity+import Data.Semigroup++#ifdef __GLASGOW_HASKELL__+import Data.Data++instance (Typeable s, Typeable1 w) => Typeable1 (EnvT s w) where+ typeOf1 dswa = mkTyConApp envTTyCon [typeOf (s dswa), typeOf1 (w dswa)]+ where+ s :: EnvT s w a -> s+ s = undefined+ w :: EnvT s w a -> w a+ w = undefined++envTTyCon :: TyCon+#if __GLASGOW_HASKELL__ < 704+envTTyCon = mkTyCon "Control.Comonad.Trans.Env.EnvT"+#else+envTTyCon = mkTyCon3 "comonad-transformers" "Control.Comonad.Trans.Env" "EnvT"+#endif+{-# NOINLINE envTTyCon #-}++instance (Typeable s, Typeable1 w, Typeable a) => Typeable (EnvT s w a) where+ typeOf = typeOfDefault++instance+ ( Data e+ , Typeable1 w, Data (w a)+ , Data a+ ) => Data (EnvT e w a) where+ gfoldl f z (EnvT e wa) = z EnvT `f` e `f` wa+ toConstr _ = envTConstr+ gunfold k z c = case constrIndex c of+ 1 -> k (k (z EnvT))+ _ -> error "gunfold"+ dataTypeOf _ = envTDataType+ dataCast1 f = gcast1 f++envTConstr :: Constr+envTConstr = mkConstr envTDataType "EnvT" [] Prefix+{-# NOINLINE envTConstr #-}++envTDataType :: DataType+envTDataType = mkDataType "Control.Comonad.Trans.Env.EnvT" [envTConstr]+{-# NOINLINE envTDataType #-}++#endif++type Env e = EnvT e Identity+data EnvT e w a = EnvT e (w a)++env :: e -> a -> Env e a+env e a = EnvT e (Identity a)++runEnv :: Env e a -> (e, a)+runEnv (EnvT e (Identity a)) = (e, a)++runEnvT :: EnvT e w a -> (e, w a)+runEnvT (EnvT e wa) = (e, wa)++instance Functor w => Functor (EnvT e w) where+ fmap g (EnvT e wa) = EnvT e (fmap g wa)++instance Extend w => Extend (EnvT e w) where+ duplicate (EnvT e wa) = EnvT e (extend (EnvT e) wa)++instance Comonad w => Comonad (EnvT e w) where+ extract (EnvT _ wa) = extract wa++instance ComonadTrans (EnvT e) where+ lower (EnvT _ wa) = wa++lowerEnvT :: EnvT e w a -> w a+lowerEnvT (EnvT _ wa) = wa++instance ComonadHoist (EnvT e) where+ cohoist (EnvT e wa) = EnvT e (Identity (extract wa))++instance (Semigroup e, Apply w) => Apply (EnvT e w) where+ EnvT ef wf <.> EnvT ea wa = EnvT (ef <> ea) (wf <.> wa)++instance Foldable w => Foldable (EnvT e w) where+ foldMap f (EnvT _ w) = foldMap f w++instance Traversable w => Traversable (EnvT e w) where+ traverse f (EnvT e w) = EnvT e <$> traverse f w++ask :: EnvT e w a -> e+ask (EnvT e _) = e++asks :: (e -> f) -> EnvT e w a -> f+asks f (EnvT e _) = f e++local :: (e -> e) -> EnvT e w a -> EnvT e w a+local f (EnvT e wa) = EnvT (f e) wa+
− Control/Comonad/Trans/Env/Lazy.hs
@@ -1,136 +0,0 @@-{-# LANGUAGE CPP, FlexibleContexts #-}--------------------------------------------------------------------------------- |--- Module : Control.Comonad.Trans.Env.Lazy--- Copyright : (C) 2008-2011 Edward Kmett--- License : BSD-style (see the file LICENSE)------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable------ The environment comonad transformer (aka coreader).--- This adds an extra value that can be accessed in the environment.------ Left adjoint to the reader comonad.------------------------------------------------------------------------------module Control.Comonad.Trans.Env.Lazy- ( - -- * The environment comonad- Env- , env- , runEnv- -- * The environment comonad transformer- , EnvT(..)- , runEnvT- , lowerEnvT- -- * Combinators- , ask- , asks- , local- -- , liftCallCV- ) where--import Control.Applicative-import Control.Comonad-import Control.Comonad.Hoist.Class-import Control.Comonad.Trans.Class-import Data.Functor.Apply-import Data.Functor.Identity-import Data.Foldable-import Data.Traversable-import Data.Semigroup--#ifdef __GLASGOW_HASKELL__-import Data.Data--instance (Typeable s, Typeable1 w) => Typeable1 (EnvT s w) where- typeOf1 dswa = mkTyConApp envTTyCon [typeOf (s dswa), typeOf1 (w dswa)]- where- s :: EnvT s w a -> s- s = undefined- w :: EnvT s w a -> w a- w = undefined--envTTyCon :: TyCon-envTTyCon = mkTyCon "Control.Comonad.Trans.Env.Lazy.EnvT"-{-# NOINLINE envTTyCon #-}--instance (Typeable s, Typeable1 w, Typeable a) => Typeable (EnvT s w a) where- typeOf = typeOfDefault--instance- ( Data e- , Typeable1 w, Data (w a)- , Data a- ) => Data (EnvT e w a) where- gfoldl f z (EnvT e wa) = z EnvT `f` e `f` wa- toConstr _ = envTConstr- gunfold k z c = case constrIndex c of- 1 -> k (k (z EnvT))- _ -> error "gunfold"- dataTypeOf _ = envTDataType- dataCast1 f = gcast1 f--envTConstr :: Constr-envTConstr = mkConstr envTDataType "EnvT" [] Prefix-{-# NOINLINE envTConstr #-}--envTDataType :: DataType-envTDataType = mkDataType "Control.Comonad.Trans.Env.Lazy.EnvT" [envTConstr]-{-# NOINLINE envTDataType #-}--#endif--type Env e = EnvT e Identity-data EnvT e w a = EnvT e (w a)--env :: e -> a -> Env e a-env e a = EnvT e (Identity a)--runEnv :: Env e a -> (e, a)-runEnv ~(EnvT e (Identity a)) = (e, a)--runEnvT :: EnvT e w a -> (e, w a)-runEnvT ~(EnvT e wa) = (e, wa)--instance Functor w => Functor (EnvT e w) where- fmap g ~(EnvT e wa) = EnvT e (fmap g wa)--instance Extend w => Extend (EnvT e w) where- duplicate ~(EnvT e wa) = EnvT e (extend (EnvT e) wa)--instance Comonad w => Comonad (EnvT e w) where- extract ~(EnvT _ wa) = extract wa--instance (Semigroup e, Apply w) => Apply (EnvT e w) where- ~(EnvT ef wf) <.> ~(EnvT ea wa) = EnvT (ef <> ea) (wf <.> wa)--instance ComonadTrans (EnvT e) where- lower (EnvT _ wa) = wa--instance ComonadHoist (EnvT e) where- cohoist ~(EnvT e wa) = EnvT e (Identity (extract wa))--instance Foldable w => Foldable (EnvT e w) where- foldMap f ~(EnvT _ w) = foldMap f w--instance Traversable w => Traversable (EnvT e w) where- traverse f (EnvT e w) = EnvT e <$> traverse f w--ask :: EnvT e w a -> e-ask (EnvT e _) = e--asks :: (e -> f) -> EnvT e w a -> f-asks f = f . ask--local :: (e -> e) -> EnvT e w a -> EnvT e w a-local f ~(EnvT e wa) = EnvT (f e) wa--lowerEnvT :: EnvT e w a -> w a -lowerEnvT (EnvT _ wa) = wa--{--liftCallCV :: Functor w => (w (w (w a -> a) -> b) -> b) -> EnvT e w (EnvT e w (EnvT e w a -> a) -> b) -> b-liftCallCV callCV ~(EnvT e wa) = callCV $ \c -> ...--}
− Control/Comonad/Trans/Env/Strict.hs
@@ -1,130 +0,0 @@-{-# LANGUAGE CPP, FlexibleContexts #-}--------------------------------------------------------------------------------- |--- Module : Control.Comonad.Trans.Env.Strict--- Copyright : (C) 2008-2011 Edward Kmett--- License : BSD-style (see the file LICENSE)------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable------ The environment comonad transformer (aka coreader).--- This adds an extra value that can be accessed in the environment.------ Left adjoint to the reader comonad.------------------------------------------------------------------------------module Control.Comonad.Trans.Env.Strict- ( - -- * The strict environment comonad- Env- , env- , runEnv- -- * The strict environment comonad transformer- , EnvT(..)- , runEnvT- , lowerEnvT- -- * Combinators- , ask- , asks- , local- ) where--import Control.Comonad-import Control.Comonad.Hoist.Class-import Control.Comonad.Trans.Class-import Data.Foldable-import Data.Traversable-import Data.Functor.Apply-import Data.Functor.Identity-import Data.Semigroup--#ifdef __GLASGOW_HASKELL__-import Data.Data--instance (Typeable s, Typeable1 w) => Typeable1 (EnvT s w) where- typeOf1 dswa = mkTyConApp envTTyCon [typeOf (s dswa), typeOf1 (w dswa)]- where- s :: EnvT s w a -> s- s = undefined- w :: EnvT s w a -> w a- w = undefined--envTTyCon :: TyCon-envTTyCon = mkTyCon "Control.Comonad.Trans.Env.Strict.EnvT"-{-# NOINLINE envTTyCon #-}--instance (Typeable s, Typeable1 w, Typeable a) => Typeable (EnvT s w a) where- typeOf = typeOfDefault--instance- ( Data e- , Typeable1 w, Data (w a)- , Data a- ) => Data (EnvT e w a) where- gfoldl f z (EnvT e wa) = z EnvT `f` e `f` wa- toConstr _ = envTConstr- gunfold k z c = case constrIndex c of- 1 -> k (k (z EnvT))- _ -> error "gunfold"- dataTypeOf _ = envTDataType- dataCast1 f = gcast1 f--envTConstr :: Constr-envTConstr = mkConstr envTDataType "EnvT" [] Prefix-{-# NOINLINE envTConstr #-}--envTDataType :: DataType-envTDataType = mkDataType "Control.Comonad.Trans.Env.Strict.EnvT" [envTConstr]-{-# NOINLINE envTDataType #-}--#endif--type Env e = EnvT e Identity-data EnvT e w a = EnvT e (w a)--env :: e -> a -> Env e a-env e a = EnvT e (Identity a)--runEnv :: Env e a -> (e, a)-runEnv (EnvT e (Identity a)) = (e, a)--runEnvT :: EnvT e w a -> (e, w a)-runEnvT (EnvT e wa) = (e, wa)--instance Functor w => Functor (EnvT e w) where- fmap g (EnvT e wa) = EnvT e (fmap g wa)--instance Extend w => Extend (EnvT e w) where- duplicate (EnvT e wa) = EnvT e (extend (EnvT e) wa)--instance Comonad w => Comonad (EnvT e w) where- extract (EnvT _ wa) = extract wa--instance ComonadTrans (EnvT e) where- lower (EnvT _ wa) = wa--lowerEnvT :: EnvT e w a -> w a-lowerEnvT (EnvT _ wa) = wa--instance ComonadHoist (EnvT e) where- cohoist (EnvT e wa) = EnvT e (Identity (extract wa))--instance (Semigroup e, Apply w) => Apply (EnvT e w) where- EnvT ef wf <.> EnvT ea wa = EnvT (ef <> ea) (wf <.> wa)--instance Foldable w => Foldable (EnvT e w) where- foldMap f (EnvT _ w) = foldMap f w--instance Traversable w => Traversable (EnvT e w) where- traverse f (EnvT e w) = EnvT e <$> traverse f w--ask :: EnvT e w a -> e-ask (EnvT e _) = e--asks :: (e -> f) -> EnvT e w a -> f-asks f (EnvT e _) = f e--local :: (e -> e) -> EnvT e w a -> EnvT e w a-local f (EnvT e wa) = EnvT (f e) wa-
Control/Comonad/Trans/Store.hs view
@@ -1,6 +1,7 @@+{-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- -- |--- Module : Control.Comonad.Trans.Context+-- Module : Control.Comonad.Trans.Store -- Copyright : (C) 2008-2011 Edward Kmett -- License : BSD-style (see the file LICENSE) --@@ -8,13 +9,116 @@ -- Stability : provisional -- Portability : portable ----- The store comonad transformer (aka costate).--- This version is lazy; for a strict version, see--- "Control.Comonad.Trans.Store.Strict", which has the same interface.+-- 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. ---------------------------------------------------------------------------- module Control.Comonad.Trans.Store- ( module Control.Comonad.Trans.Store.Lazy+ (+ -- * The Store comonad+ Store, store, runStore+ -- * The Store comonad transformer+ , StoreT(..), runStoreT+ -- * Operations+ , pos+ , seek, seeks+ , peek, peeks ) where -import Control.Comonad.Trans.Store.Lazy+import Control.Applicative+import Control.Comonad+import Control.Comonad.Hoist.Class+import Control.Comonad.Trans.Class+import Data.Functor.Identity+import Data.Functor.Apply+import Data.Semigroup++#ifdef __GLASGOW_HASKELL__+import Data.Typeable+instance (Typeable s, Typeable1 w) => Typeable1 (StoreT s w) where+ typeOf1 dswa = mkTyConApp storeTTyCon [typeOf (s dswa), typeOf1 (w dswa)]+ where+ s :: StoreT s w a -> s+ s = undefined+ w :: StoreT s w a -> w a+ w = undefined++instance (Typeable s, Typeable1 w, Typeable a) => Typeable (StoreT s w a) where+ typeOf = typeOfDefault++storeTTyCon :: TyCon+#if __GLASGOW_HASKELL__ < 704+storeTTyCon = mkTyCon "Control.Comonad.Trans.Store.StoreT"+#else+storeTTyCon = mkTyCon3 "comonad-transformers" "Control.Comonad.Trans.Store" "StoreT"+#endif+{-# NOINLINE storeTTyCon #-}+#endif++type Store s = StoreT s Identity++store :: (s -> a) -> s -> Store s a+store f s = StoreT (Identity f) s++runStore :: Store s a -> (s -> a, s)+runStore (StoreT (Identity f) s) = (f, s)++data StoreT s w a = StoreT (w (s -> a)) s++runStoreT :: StoreT s w a -> (w (s -> a), s)+runStoreT (StoreT wf s) = (wf, s)++instance Functor w => Functor (StoreT s w) where+ fmap f (StoreT wf s) = StoreT (fmap (f .) wf) s++instance (Apply w, Semigroup s) => Apply (StoreT s w) where+ StoreT ff m <.> StoreT fa n = StoreT ((<*>) <$> ff <.> fa) (m <> n)++instance (Applicative w, Semigroup s, Monoid s) => Applicative (StoreT s w) where+ pure a = StoreT (pure (const a)) mempty+ StoreT ff m <*> StoreT fa n = StoreT ((<*>) <$> ff <*> fa) (m `mappend` n)++instance Extend w => Extend (StoreT s w) where+ duplicate (StoreT wf s) = StoreT (extend StoreT wf) s+ extend f (StoreT wf s) = StoreT (extend (\wf' s' -> f (StoreT wf' s')) wf) s++instance Comonad w => Comonad (StoreT s w) where+ extract (StoreT wf s) = extract wf s++instance ComonadTrans (StoreT s) where+ lower (StoreT f s) = fmap ($s) f++instance ComonadHoist (StoreT s) where+ cohoist (StoreT f s) = StoreT (Identity (extract f)) s++-- | Read the current position+pos :: StoreT s w a -> s+pos (StoreT _ s) = s++-- | Seek to an absolute location+--+-- > seek s = peek s . duplicate+seek :: Comonad w => s -> StoreT s w a -> StoreT s w a+seek s ~(StoreT f _) = StoreT f s++-- | Seek to a relative location+--+-- > seeks f = peeks f . duplicate+seeks :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a+seeks f ~(StoreT g s) = StoreT g (f s)++-- | Peek at a value at a given absolute location+--+-- > peek x . extend (peek y) = peek y+peek :: Comonad w => s -> StoreT s w a -> a+peek s (StoreT g _) = extract g s++-- | Peek at a value at a given relative location+peeks :: Comonad w => (s -> s) -> StoreT s w a -> a+peeks f ~(StoreT g s) = extract g (f s)+
− Control/Comonad/Trans/Store/Lazy.hs
@@ -1,119 +0,0 @@-{-# LANGUAGE CPP #-}--------------------------------------------------------------------------------- |--- Module : Control.Comonad.Trans.Store.Lazy--- Copyright : (C) 2008-2011 Edward Kmett--- License : BSD-style (see the file LICENSE)------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable------ The lazy 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.Trans.Store.Lazy- ( - -- * The Store comonad- Store, store, runStore- -- * The Store comonad transformer- , StoreT(..), runStoreT- -- * Operations- , pos- , seek, seeks- , peek, peeks- ) where--import Control.Applicative-import Control.Comonad-import Control.Comonad.Hoist.Class-import Control.Comonad.Trans.Class-import Data.Functor.Identity-import Data.Functor.Apply-import Data.Semigroup--#ifdef __GLASGOW_HASKELL__-import Data.Typeable-instance (Typeable s, Typeable1 w) => Typeable1 (StoreT s w) where- typeOf1 dswa = mkTyConApp storeTTyCon [typeOf (s dswa), typeOf1 (w dswa)]- where- s :: StoreT s w a -> s- s = undefined- w :: StoreT s w a -> w a- w = undefined--instance (Typeable s, Typeable1 w, Typeable a) => Typeable (StoreT s w a) where- typeOf = typeOfDefault--storeTTyCon :: TyCon-storeTTyCon = mkTyCon "Control.Comonad.Trans.Store.Lazy.StoreT"-{-# NOINLINE storeTTyCon #-}-#endif--type Store s = StoreT s Identity--store :: (s -> a) -> s -> Store s a -store f s = StoreT (Identity f) s--runStore :: Store s a -> (s -> a, s)-runStore ~(StoreT (Identity f) s) = (f, s)--data StoreT s w a = StoreT (w (s -> a)) s--runStoreT :: StoreT s w a -> (w (s -> a), s)-runStoreT ~(StoreT wf s) = (wf, s)--instance Functor w => Functor (StoreT s w) where- fmap f ~(StoreT wf s) = StoreT (fmap (f .) wf) s--instance (Apply w, Semigroup s) => Apply (StoreT s w) where- ~(StoreT ff m) <.> ~(StoreT fa n) = StoreT ((<*>) <$> ff <.> fa) (m <> n)--instance (Applicative w, Semigroup s, Monoid s) => Applicative (StoreT s w) where- pure a = StoreT (pure (const a)) mempty- ~(StoreT ff m) <*> ~(StoreT fa n) = StoreT ((<*>) <$> ff <*> fa) (m `mappend` n)--instance Extend w => Extend (StoreT s w) where- duplicate ~(StoreT wf s) = StoreT (extend StoreT wf) s- extend f ~(StoreT wf s) = StoreT (extend (\wf' s' -> f (StoreT wf' s')) wf) s--instance Comonad w => Comonad (StoreT s w) where- extract ~(StoreT wf s) = extract wf s--instance ComonadTrans (StoreT s) where- lower ~(StoreT f s) = fmap ($s) f--instance ComonadHoist (StoreT s) where- cohoist ~(StoreT f s) = StoreT (Identity (extract f)) s---- | Read the current position-pos :: StoreT s w a -> s-pos (StoreT _ s) = s---- | Seek to an absolute location------ > seek s = peek s . duplicate-seek :: Comonad w => s -> StoreT s w a -> StoreT s w a -seek s ~(StoreT f _) = StoreT f s---- | Seek to a relative location------ > seeks f = peeks f . duplicate-seeks :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a-seeks f ~(StoreT g s) = StoreT g (f s)---- | Peek at a value at a given absolute location------ > peek x . extend (peek y) = peek y-peek :: Comonad w => s -> StoreT s w a -> a-peek s (StoreT g _) = extract g s---- | Peek at a value at a given relative location-peeks :: Comonad w => (s -> s) -> StoreT s w a -> a-peeks f ~(StoreT g s) = extract g (f s)
− Control/Comonad/Trans/Store/Memo.hs
@@ -1,131 +0,0 @@-{-# LANGUAGE CPP #-}--------------------------------------------------------------------------------- |--- Module : Control.Comonad.Trans.Store.Memo--- Copyright : (C) 2008-2011 Edward Kmett--- License : BSD-style (see the file LICENSE)------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable------ The 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)------ 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.------------------------------------------------------------------------------module Control.Comonad.Trans.Store.Memo- ( - -- * The Store comonad- Store, store, runStore- -- * The Store comonad transformer- , StoreT, storeT, runStoreT- , lowerStoreT- -- * Operations- , pos- , seek, seeks- , peek, peeks- ) where--import Control.Applicative-import Control.Comonad-import Control.Comonad.Hoist.Class-import Control.Comonad.Trans.Class-import Data.Functor.Identity-import Data.Functor.Apply-import Data.Semigroup--#ifdef __GLASGOW_HASKELL__-import Data.Typeable-instance (Typeable s, Typeable1 w) => Typeable1 (StoreT s w) where- typeOf1 dswa = mkTyConApp storeTTyCon [typeOf (s dswa), typeOf1 (w dswa)]- where- s :: StoreT s w a -> s- s = undefined- w :: StoreT s w a -> w a- w = undefined--instance (Typeable s, Typeable1 w, Typeable a) => Typeable (StoreT s w a) where- typeOf = typeOfDefault--storeTTyCon :: TyCon-storeTTyCon = mkTyCon "Control.Comonad.Trans.Store.Memo.StoreT"-{-# NOINLINE storeTTyCon #-}-#endif--type Store s = StoreT s Identity--store :: (s -> a) -> s -> Store s a -store f s = StoreT (Identity f) s (Identity (f s))--runStore :: Store s a -> (s -> a, s)-runStore (StoreT (Identity f) s _) = (f, s)---- inhabitants of @StoreT wf s w@ ensure that------ > w = ($s) <$> wf-data StoreT s w a = StoreT (w (s -> a)) s (w a)--runStoreT :: StoreT s w a -> (w (s -> a), s)-runStoreT (StoreT wf s _) = (wf, s)--storeT :: Functor w => w (s -> a) -> s -> StoreT s w a-storeT wf s = StoreT wf s (fmap ($s) wf)--instance Functor w => Functor (StoreT s w) where- fmap f (StoreT wf s w) = StoreT (fmap (f .) wf) s (fmap f w)--instance (Apply w, Semigroup s) => Apply (StoreT s w) where- StoreT ff m _ <.> StoreT fa n _ = storeT ((<*>) <$> ff <.> fa) (m <> n)--instance (Applicative w, Semigroup s, Monoid s) => Applicative (StoreT s w) where- pure a = storeT (pure (const a)) mempty- StoreT ff m _ <*> StoreT fa n _ = storeT ((<*>) <$> ff <*> fa) (m `mappend` n)--instance Extend w => Extend (StoreT s w) where- duplicate (StoreT wf s _) = storeT (extend storeT wf) s --instance Comonad w => Comonad (StoreT s w) where- extract (StoreT _ _ w) = extract w--instance ComonadTrans (StoreT s) where- lower (StoreT _ _ w) = w--lowerStoreT :: StoreT s w a -> w a-lowerStoreT (StoreT _ _ w) = w--instance ComonadHoist (StoreT s) where- cohoist (StoreT f s w) = StoreT (Identity (extract f)) s (Identity (extract w))---- | Read the current position-pos :: StoreT s w a -> s-pos (StoreT _ s _) = s---- | Seek to an absolute location------ > seek s = peek s . duplicate-seek :: Comonad w => s -> StoreT s w a -> StoreT s w a-seek s (StoreT f _ _) = storeT f s---- | Seek to a relative location------ > seeks f = peeks f . duplicate-seeks :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a-seeks f (StoreT g s _) = storeT g (f s)---- | Peek at a value at a given absolute location------ > peek x . extend (peek y) = peek y-peek :: Comonad w => s -> StoreT s w a -> a-peek s (StoreT g _ _) = extract g s---- | Peek at a value at a given relative location-peeks :: Comonad w => (s -> s) -> StoreT s w a -> a-peeks f (StoreT g s _) = extract g (f s)-
− Control/Comonad/Trans/Store/Strict.hs
@@ -1,120 +0,0 @@-{-# LANGUAGE CPP #-}--------------------------------------------------------------------------------- |--- Module : Control.Comonad.Trans.Store.Strict--- Copyright : (C) 2008-2011 Edward Kmett--- License : BSD-style (see the file LICENSE)------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable------ 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.------------------------------------------------------------------------------module Control.Comonad.Trans.Store.Strict- ( - -- * The Store comonad- Store, store, runStore- -- * The Store comonad transformer- , StoreT(..), runStoreT- -- * Operations- , pos- , seek, seeks- , peek, peeks- ) where--import Control.Applicative-import Control.Comonad-import Control.Comonad.Hoist.Class-import Control.Comonad.Trans.Class-import Data.Functor.Identity-import Data.Functor.Apply-import Data.Semigroup--#ifdef __GLASGOW_HASKELL__-import Data.Typeable-instance (Typeable s, Typeable1 w) => Typeable1 (StoreT s w) where- typeOf1 dswa = mkTyConApp storeTTyCon [typeOf (s dswa), typeOf1 (w dswa)]- where- s :: StoreT s w a -> s- s = undefined- w :: StoreT s w a -> w a- w = undefined--instance (Typeable s, Typeable1 w, Typeable a) => Typeable (StoreT s w a) where- typeOf = typeOfDefault--storeTTyCon :: TyCon-storeTTyCon = mkTyCon "Control.Comonad.Trans.Store.Strict.StoreT"-{-# NOINLINE storeTTyCon #-}-#endif--type Store s = StoreT s Identity--store :: (s -> a) -> s -> Store s a -store f s = StoreT (Identity f) s--runStore :: Store s a -> (s -> a, s)-runStore (StoreT (Identity f) s) = (f, s)--data StoreT s w a = StoreT (w (s -> a)) s--runStoreT :: StoreT s w a -> (w (s -> a), s)-runStoreT (StoreT wf s) = (wf, s)--instance Functor w => Functor (StoreT s w) where- fmap f (StoreT wf s) = StoreT (fmap (f .) wf) s--instance (Apply w, Semigroup s) => Apply (StoreT s w) where- StoreT ff m <.> StoreT fa n = StoreT ((<*>) <$> ff <.> fa) (m <> n)--instance (Applicative w, Semigroup s, Monoid s) => Applicative (StoreT s w) where- pure a = StoreT (pure (const a)) mempty- StoreT ff m <*> StoreT fa n = StoreT ((<*>) <$> ff <*> fa) (m `mappend` n)--instance Extend w => Extend (StoreT s w) where- duplicate (StoreT wf s) = StoreT (extend StoreT wf) s- extend f (StoreT wf s) = StoreT (extend (\wf' s' -> f (StoreT wf' s')) wf) s--instance Comonad w => Comonad (StoreT s w) where- extract (StoreT wf s) = extract wf s--instance ComonadTrans (StoreT s) where- lower (StoreT f s) = fmap ($s) f--instance ComonadHoist (StoreT s) where- cohoist (StoreT f s) = StoreT (Identity (extract f)) s---- | Read the current position-pos :: StoreT s w a -> s-pos (StoreT _ s) = s---- | Seek to an absolute location------ > seek s = peek s . duplicate-seek :: Comonad w => s -> StoreT s w a -> StoreT s w a-seek s ~(StoreT f _) = StoreT f s---- | Seek to a relative location------ > seeks f = peeks f . duplicate-seeks :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a-seeks f ~(StoreT g s) = StoreT g (f s)---- | Peek at a value at a given absolute location------ > peek x . extend (peek y) = peek y-peek :: Comonad w => s -> StoreT s w a -> a-peek s (StoreT g _) = extract g s---- | Peek at a value at a given relative location-peeks :: Comonad w => (s -> s) -> StoreT s w a -> a-peeks f ~(StoreT g s) = extract g (f s)-
Control/Comonad/Trans/Traced.hs view
@@ -12,7 +12,7 @@ -- ---------------------------------------------------------------------------- module Control.Comonad.Trans.Traced- ( + ( -- * Traced comonad Traced , traced@@ -27,13 +27,12 @@ ) where import Control.Applicative-import Control.Monad.Instances+import Control.Monad.Instances () import Control.Monad (ap) import Control.Comonad import Control.Comonad.Hoist.Class import Control.Comonad.Trans.Class import Data.Distributive-import Data.Functor import Data.Functor.Apply import Data.Functor.Identity import Data.Semigroup@@ -56,7 +55,7 @@ TracedT wf <.> TracedT wa = TracedT (ap <$> wf <.> wa) instance Applicative w => Applicative (TracedT m w) where- pure = TracedT . pure . const + pure = TracedT . pure . const TracedT wf <*> TracedT wa = TracedT (ap <$> wf <*> wa) instance (Extend w, Semigroup m) => Extend (TracedT m w) where@@ -81,7 +80,7 @@ listen = TracedT . fmap (\f m -> (f m, m)) . runTracedT listens :: Functor w => (m -> b) -> TracedT m w a -> TracedT m w (a, b)-listens g = TracedT . fmap (\f m -> (f m, g m)) . runTracedT +listens g = TracedT . fmap (\f m -> (f m, g m)) . runTracedT censor :: Functor w => (m -> m) -> TracedT m w a -> TracedT m w a censor g = TracedT . fmap (. g) . runTracedT@@ -97,7 +96,11 @@ w = undefined tracedTTyCon :: TyCon+#if __GLASGOW_HASKELL__ < 704 tracedTTyCon = mkTyCon "Control.Comonad.Trans.Traced.TracedT"+#else+tracedTTyCon = mkTyCon3 "comonad-transformers" "Control.Comonad.Trans.Traced" "TracedT"+#endif {-# NOINLINE tracedTTyCon #-} #endif
− Control/Comonad/Trans/Traced/Memo.hs
@@ -1,109 +0,0 @@-{-# LANGUAGE CPP #-}--------------------------------------------------------------------------------- |--- Module : Control.Comonad.Trans.Traced.Memo--- Copyright : (C) 2008-2011 Edward Kmett--- License : BSD-style (see the file LICENSE)------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable------ The memoized traced comonad transformer (aka the cowriter or --- exponential comonad transformer).---------------------------------------------------------------------------------module Control.Comonad.Trans.Traced.Memo- ( - -- * Traced comonad- Traced- , traced- , runTraced- -- * Traced comonad transformer- , TracedT- , tracedT- , runTracedT- -- * Operations- , trace- , listen- , listens- , censor- ) where--import Control.Applicative-import Control.Monad.Instances-import Control.Monad (ap)-import Control.Comonad-import Control.Comonad.Hoist.Class-import Control.Comonad.Trans.Class-import Data.Functor-import Data.Functor.Apply-import Data.Functor.Identity-import Data.Semigroup-import Data.Typeable--type Traced m = TracedT m Identity--traced :: Monoid m => (m -> a) -> Traced m a-traced f = TracedT (Identity f) (Identity (f mempty))--runTraced :: Traced m a -> m -> a-runTraced (TracedT (Identity f) _) = f--data TracedT m w a = TracedT (w (m -> a)) (w a)--runTracedT :: TracedT m w a -> w (m -> a)-runTracedT (TracedT wf _) = wf--tracedT :: (Functor w, Monoid m) => w (m -> a) -> TracedT m w a -tracedT wf = TracedT wf (fmap ($ mempty) wf)--instance Functor w => Functor (TracedT m w) where- fmap g (TracedT wf wa) = TracedT ((g .) <$> wf) (g <$> wa)--instance Apply w => Apply (TracedT m w) where- TracedT wf wf' <.> TracedT wa wa' = TracedT (ap <$> wf <.> wa) (wf' <.> wa')--instance Applicative w => Applicative (TracedT m w) where- pure a = TracedT (pure (const a)) (pure a)- TracedT wf wf' <*> TracedT wa wa' = TracedT (ap <$> wf <*> wa) (wf' <*> wa')--instance (Extend w, Monoid m) => Extend (TracedT m w) where- extend f = tracedT . extend (\wf m -> f (tracedT (fmap (. mappend m) wf))) . runTracedT--instance (Comonad w, Monoid m) => Comonad (TracedT m w) where- extract (TracedT _ wa) = extract wa--instance ComonadTrans (TracedT m) where- lower (TracedT _ wa) = wa--instance ComonadHoist (TracedT m) where- cohoist (TracedT wf wa) = TracedT (Identity (extract wf)) (Identity (extract wa))--trace :: (Comonad w, Monoid m) => m -> TracedT m w a -> a-trace m (TracedT wf _) = extract wf m--listen :: (Functor w, Monoid m) => TracedT m w a -> TracedT m w (a, m)-listen (TracedT wf wa) = TracedT (fmap (\f m -> (f m, m)) wf) (fmap (\a -> (a,mempty)) wa)--listens :: (Functor w, Monoid m) => (m -> b) -> TracedT m w a -> TracedT m w (a, b)-listens g (TracedT wf wa) = TracedT (fmap (\f m -> (f m, g m)) wf) (fmap (\a -> (a, g mempty)) wa)--censor :: (Functor w, Monoid m) => (m -> m) -> TracedT m w a -> TracedT m w a-censor g = tracedT . fmap (. g) . runTracedT--#ifdef __GLASGOW_HASKELL__--instance (Typeable s, Typeable1 w) => Typeable1 (TracedT s w) where- typeOf1 dswa = mkTyConApp tracedTTyCon [typeOf (s dswa), typeOf1 (w dswa)]- where- s :: TracedT s w a -> s- s = undefined- w :: TracedT s w a -> w a- w = undefined--tracedTTyCon :: TyCon-tracedTTyCon = mkTyCon "Control.Comonad.Trans.Traced.Memo.TracedT"-{-# NOINLINE tracedTTyCon #-}--#endif
comonad-transformers.cabal view
@@ -1,6 +1,6 @@ name: comonad-transformers category: Control, Comonads-version: 2.0.3+version: 2.1 license: BSD3 cabal-version: >= 1.6 license-file: LICENSE@@ -8,11 +8,11 @@ maintainer: Edward A. Kmett <ekmett@gmail.com> stability: provisional homepage: http://github.com/ekmett/comonad-transformers/-copyright: Copyright (C) 2008-2011 Edward A. Kmett+copyright: Copyright (C) 2008-2012 Edward A. Kmett synopsis: Comonad transformers description: Comonad transformers build-type: Simple-extra-source-files: coq/Store.v+extra-source-files: coq/Store.v CHANGELOG source-repository head type: git@@ -23,15 +23,15 @@ default: True library- build-depends: + build-depends: base >= 4 && < 5,- comonad >= 1.1.1.1 && < 1.2,+ comonad >= 1.1.1.3 && < 1.2, containers >= 0.3 && < 0.5,- contravariant >= 0.1.2 && < 0.2,- distributive >= 0.2 && < 0.3,- semigroupoids >= 1.2.6.1 && < 1.3,- semigroups >= 0.8 && < 0.9,- transformers >= 0.2.0 && < 0.3+ contravariant >= 0.2.0.1 && < 0.3,+ distributive >= 0.2.1 && < 0.3,+ semigroupoids >= 1.3 && < 1.4,+ semigroups >= 0.8.2 && < 0.9,+ transformers >= 0.3 && < 0.4 if flag(DeriveDataTypeable) extensions: DeriveDataTypeable@@ -42,22 +42,11 @@ exposed-modules: Control.Comonad.Hoist.Class Control.Comonad.Trans.Class- Control.Comonad.Trans.Discont- Control.Comonad.Trans.Discont.Lazy- Control.Comonad.Trans.Discont.Strict- Control.Comonad.Trans.Discont.Memo Control.Comonad.Trans.Env- Control.Comonad.Trans.Env.Lazy- Control.Comonad.Trans.Env.Strict Control.Comonad.Trans.Identity Control.Comonad.Trans.Store- Control.Comonad.Trans.Store.Lazy- Control.Comonad.Trans.Store.Strict- Control.Comonad.Trans.Store.Memo Control.Comonad.Trans.Traced- Control.Comonad.Trans.Traced.Memo- Data.Functor.Coproduct Data.Functor.Composition - ghc-options: -Wall + ghc-options: -Wall