-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Adjunctions and representable functors -- -- Adjunctions and representable functors @package adjunctions @version 4.3 -- | Representable contravariant endofunctors over the category of Haskell -- types are isomorphic to (_ -> r) and resemble mappings to -- a fixed range. module Data.Functor.Contravariant.Rep -- | A Contravariant functor f is Representable if -- tabulate and index witness an isomorphism to (_ -- -> Rep f). -- --
--   tabulate . index ≡ id
--   index . tabulate ≡ id
--   
class Contravariant f => Representable f where type family Rep f :: * contramapWithRep f p = tabulate $ either (index p) id . f -- |
--   contramap f (tabulate g) = tabulate (g . f)
--   
tabulate :: Representable f => (a -> Rep f) -> f a index :: Representable f => f a -> a -> Rep f -- |
--   contramapWithRep f p ≡ tabulate $ either (index p) id . f
--   
contramapWithRep :: Representable f => (b -> Either a (Rep f)) -> f a -> f b -- | tabulate and index form two halves of an isomorphism. -- -- This can be used with the combinators from the lens package. -- --
--   tabulated :: Representable f => Iso' (a -> Rep f) (f a)
--   
tabulated :: (Representable f, Representable g, Profunctor p, Functor h) => p (f a) (h (g b)) -> p (a -> Rep f) (h (b -> Rep g)) contramapRep :: Representable f => (a -> b) -> f b -> f a instance Data.Functor.Contravariant.Rep.Representable Data.Proxy.Proxy instance Data.Functor.Contravariant.Rep.Representable (Data.Functor.Contravariant.Op r) instance Data.Functor.Contravariant.Rep.Representable Data.Functor.Contravariant.Predicate instance (Data.Functor.Contravariant.Rep.Representable f, Data.Functor.Contravariant.Rep.Representable g) => Data.Functor.Contravariant.Rep.Representable (Data.Functor.Product.Product f g) -- |
--   Cont r ~ Contravariant.Adjoint (Op r) (Op r)
--   Conts r ~ Contravariant.AdjointT (Op r) (Op r)
--   ContsT r w m ~ Contravariant.AdjointT (Op (m r)) (Op (m r)) w
--   
module Control.Monad.Trans.Conts type Cont r = ContsT r Identity Identity cont :: ((a -> r) -> r) -> Cont r a runCont :: Cont r a -> (a -> r) -> r type Conts r w = ContsT r w Identity runConts :: Functor w => Conts r w a -> w (a -> r) -> r conts :: Functor w => (w (a -> r) -> r) -> Conts r w a newtype ContsT r w m a ContsT :: (w (a -> m r) -> m r) -> ContsT r w m a [runContsT] :: ContsT r w m a -> w (a -> m r) -> m r callCC :: Comonad w => ((a -> ContsT r w m b) -> ContsT r w m a) -> ContsT r w m a instance GHC.Base.Functor w => GHC.Base.Functor (Control.Monad.Trans.Conts.ContsT r w m) instance Control.Comonad.Comonad w => Data.Functor.Bind.Class.Apply (Control.Monad.Trans.Conts.ContsT r w m) instance Control.Comonad.Comonad w => GHC.Base.Applicative (Control.Monad.Trans.Conts.ContsT r w m) instance Control.Comonad.Comonad w => GHC.Base.Monad (Control.Monad.Trans.Conts.ContsT r w m) instance Control.Comonad.Comonad w => Control.Monad.Trans.Class.MonadTrans (Control.Monad.Trans.Conts.ContsT r w) module Data.Functor.Contravariant.Adjunction -- | An adjunction from Hask^op to Hask -- --
--   Op (f a) b ~ Hask a (g b)
--   
-- --
--   rightAdjunct unit = id
--   leftAdjunct counit = id
--   
-- -- Any adjunction from Hask to Hask^op would indirectly -- permit unsafePerformIO, and therefore does not exist. class (Contravariant f, Representable g) => Adjunction f g | f -> g, g -> f where unit = leftAdjunct id counit = rightAdjunct id leftAdjunct f = contramap f . unit rightAdjunct f = contramap f . counit unit :: Adjunction f g => a -> g (f a) counit :: Adjunction f g => a -> f (g a) leftAdjunct :: Adjunction f g => (b -> f a) -> a -> g b rightAdjunct :: Adjunction f g => (a -> g b) -> b -> f a -- | leftAdjunct and rightAdjunct form two halves of an -- isomorphism. -- -- This can be used with the combinators from the lens package. -- --
--   adjuncted :: Adjunction f g => Iso' (b -> f a) (a -> g b)
--   
adjuncted :: (Adjunction f g, Profunctor p, Functor h) => p (a -> g b) (h (c -> g d)) -> p (b -> f a) (h (d -> f c)) -- | Represent a Contravariant functor that has a left adjoint contrarepAdjunction :: Adjunction f g => (a -> f ()) -> g a coindexAdjunction :: Adjunction f g => g a -> a -> f () instance Data.Functor.Contravariant.Adjunction.Adjunction (Data.Functor.Contravariant.Op r) (Data.Functor.Contravariant.Op r) instance Data.Functor.Contravariant.Adjunction.Adjunction Data.Functor.Contravariant.Predicate Data.Functor.Contravariant.Predicate -- | Uses a contravariant adjunction: -- -- f -| g : Hask^op -> Hask -- -- to build a Comonad to Monad transformer. Sadly, the dual -- construction, which builds a Comonad out of a Monad, is -- uninhabited, because any Adjunction of the form -- --
--   f -| g : Hask -> Hask^op
--   
-- -- would trivially admit unsafePerformIO. module Control.Monad.Trans.Contravariant.Adjoint type Adjoint f g = AdjointT f g Identity runAdjoint :: Contravariant g => Adjoint f g a -> g (f a) adjoint :: Contravariant g => g (f a) -> Adjoint f g a newtype AdjointT f g w a AdjointT :: g (w (f a)) -> AdjointT f g w a [runAdjointT] :: AdjointT f g w a -> g (w (f a)) instance (Data.Functor.Contravariant.Adjunction.Adjunction f g, GHC.Base.Functor w) => GHC.Base.Functor (Control.Monad.Trans.Contravariant.Adjoint.AdjointT f g w) instance (Data.Functor.Contravariant.Adjunction.Adjunction f g, Control.Comonad.Comonad w) => GHC.Base.Applicative (Control.Monad.Trans.Contravariant.Adjoint.AdjointT f g w) instance (Data.Functor.Contravariant.Adjunction.Adjunction f g, Control.Comonad.Comonad w) => GHC.Base.Monad (Control.Monad.Trans.Contravariant.Adjoint.AdjointT f g w) -- | Representable endofunctors over the category of Haskell types are -- isomorphic to the reader monad and so inherit a very large number of -- properties for free. module Data.Functor.Rep -- | A Functor f is Representable if tabulate -- and index witness an isomorphism to (->) x. -- -- Every Distributive Functor is actually -- Representable. -- -- Every Representable Functor from Hask to Hask is a right -- adjoint. -- --
--   tabulate . index  ≡ id
--   index . tabulate  ≡ id
--   tabulate . returnreturn
--   
class Distributive f => Representable f where type family Rep f :: * -- |
--   fmap f . tabulatetabulate . fmap f
--   
tabulate :: Representable f => (Rep f -> a) -> f a index :: Representable f => f a -> Rep f -> a -- | tabulate and index form two halves of an isomorphism. -- -- This can be used with the combinators from the lens package. -- --
--   tabulated :: Representable f => Iso' (Rep f -> a) (f a)
--   
tabulated :: (Representable f, Representable g, Profunctor p, Functor h) => p (f a) (h (g b)) -> p (Rep f -> a) (h (Rep g -> b)) newtype Co f a Co :: f a -> Co f a [unCo] :: Co f a -> f a fmapRep :: Representable f => (a -> b) -> f a -> f b distributeRep :: (Representable f, Functor w) => w (f a) -> f (w a) apRep :: Representable f => f (a -> b) -> f a -> f b pureRep :: Representable f => a -> f a liftR2 :: Representable f => (a -> b -> c) -> f a -> f b -> f c liftR3 :: Representable f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d bindRep :: Representable f => f a -> (a -> f b) -> f b mfixRep :: Representable f => (a -> f a) -> f a mzipRep :: Representable f => f a -> f b -> f (a, b) mzipWithRep :: Representable f => (a -> b -> c) -> f a -> f b -> f c askRep :: Representable f => f (Rep f) localRep :: Representable f => (Rep f -> Rep f) -> f a -> f a duplicatedRep :: (Representable f, Semigroup (Rep f)) => f a -> f (f a) extendedRep :: (Representable f, Semigroup (Rep f)) => (f a -> b) -> f a -> f b duplicateRep :: (Representable f, Monoid (Rep f)) => f a -> f (f a) extendRep :: (Representable f, Monoid (Rep f)) => (f a -> b) -> f a -> f b extractRep :: (Representable f, Monoid (Rep f)) => f a -> a duplicateRepBy :: Representable f => (Rep f -> Rep f -> Rep f) -> f a -> f (f a) extendRepBy :: Representable f => (Rep f -> Rep f -> Rep f) -> (f a -> b) -> f a -> f b extractRepBy :: Representable f => (Rep f) -> f a -> a instance GHC.Base.Functor f => GHC.Base.Functor (Data.Functor.Rep.Co f) instance Data.Functor.Rep.Representable Data.Proxy.Proxy instance Data.Functor.Rep.Representable Data.Functor.Identity.Identity instance Data.Functor.Rep.Representable (Data.Tagged.Tagged t) instance Data.Functor.Rep.Representable m => Data.Functor.Rep.Representable (Control.Monad.Trans.Identity.IdentityT m) instance Data.Functor.Rep.Representable ((->) e) instance Data.Functor.Rep.Representable m => Data.Functor.Rep.Representable (Control.Monad.Trans.Reader.ReaderT e m) instance (Data.Functor.Rep.Representable f, Data.Functor.Rep.Representable g) => Data.Functor.Rep.Representable (Data.Functor.Compose.Compose f g) instance Data.Functor.Rep.Representable w => Data.Functor.Rep.Representable (Control.Comonad.Trans.Traced.TracedT s w) instance (Data.Functor.Rep.Representable f, Data.Functor.Rep.Representable g) => Data.Functor.Rep.Representable (Data.Functor.Product.Product f g) instance Data.Functor.Rep.Representable f => Data.Functor.Rep.Representable (Control.Comonad.Cofree.Cofree f) instance Data.Functor.Rep.Representable Data.Monoid.Dual instance Data.Functor.Rep.Representable Data.Monoid.Product instance Data.Functor.Rep.Representable Data.Monoid.Sum instance Data.Functor.Rep.Representable Data.Complex.Complex instance Data.Functor.Rep.Representable f => Data.Functor.Rep.Representable (Data.Functor.Rep.Co f) instance Data.Functor.Rep.Representable f => Data.Functor.Bind.Class.Apply (Data.Functor.Rep.Co f) instance Data.Functor.Rep.Representable f => GHC.Base.Applicative (Data.Functor.Rep.Co f) instance Data.Functor.Rep.Representable f => Data.Distributive.Distributive (Data.Functor.Rep.Co f) instance Data.Functor.Rep.Representable f => Data.Functor.Bind.Class.Bind (Data.Functor.Rep.Co f) instance Data.Functor.Rep.Representable f => GHC.Base.Monad (Data.Functor.Rep.Co f) instance (Data.Functor.Rep.Representable f, Data.Functor.Rep.Rep f ~ a) => Control.Monad.Reader.Class.MonadReader a (Data.Functor.Rep.Co f) instance (Data.Functor.Rep.Representable f, Data.Semigroup.Semigroup (Data.Functor.Rep.Rep f)) => Data.Functor.Extend.Extend (Data.Functor.Rep.Co f) instance (Data.Functor.Rep.Representable f, GHC.Base.Monoid (Data.Functor.Rep.Rep f)) => Control.Comonad.Comonad (Data.Functor.Rep.Co f) instance Control.Comonad.Trans.Class.ComonadTrans Data.Functor.Rep.Co module Data.Functor.Adjunction -- | An adjunction between Hask and Hask. -- -- Minimal definition: both unit and counit or both -- leftAdjunct and rightAdjunct, subject to the constraints -- imposed by the default definitions that the following laws should -- hold. -- --
--   unit = leftAdjunct id
--   counit = rightAdjunct id
--   leftAdjunct f = fmap f . unit
--   rightAdjunct f = counit . fmap f
--   
-- -- Any implementation is required to ensure that leftAdjunct and -- rightAdjunct witness an isomorphism from Nat (f a, b) -- to Nat (a, g b) -- --
--   rightAdjunct unit = id
--   leftAdjunct counit = id
--   
class (Functor f, Representable u) => Adjunction f u | f -> u, u -> f where unit = leftAdjunct id counit = rightAdjunct id leftAdjunct f = fmap f . unit rightAdjunct f = counit . fmap f unit :: Adjunction f u => a -> u (f a) counit :: Adjunction f u => f (u a) -> a leftAdjunct :: Adjunction f u => (f a -> b) -> a -> u b rightAdjunct :: Adjunction f u => (a -> u b) -> f a -> b -- | leftAdjunct and rightAdjunct form two halves of an -- isomorphism. -- -- This can be used with the combinators from the lens package. -- --
--   adjuncted :: Adjunction f u => Iso' (f a -> b) (a -> u b)
--   
adjuncted :: (Adjunction f u, Profunctor p, Functor g) => p (a -> u b) (g (c -> u d)) -> p (f a -> b) (g (f c -> d)) -- | Every right adjoint is representable by its left adjoint applied to a -- unit element -- -- Use this definition and the primitives in Data.Functor.Representable -- to meet the requirements of the superclasses of Representable. tabulateAdjunction :: Adjunction f u => (f () -> b) -> u b -- | This definition admits a default definition for the index -- method of 'Index", one of the superclasses of Representable. indexAdjunction :: Adjunction f u => u b -> f a -> b zapWithAdjunction :: Adjunction f u => (a -> b -> c) -> u a -> f b -> c -- | A right adjoint functor admits an intrinsic notion of zipping zipR :: Adjunction f u => (u a, u b) -> u (a, b) -- | Every functor in Haskell permits unzipping unzipR :: Functor u => u (a, b) -> (u a, u b) -- | A left adjoint must be inhabited, or we can derive bottom. unabsurdL :: Adjunction f u => f Void -> Void absurdL :: Void -> f Void -- | And a left adjoint must be inhabited by exactly one element cozipL :: Adjunction f u => f (Either a b) -> Either (f a) (f b) -- | Every functor in Haskell permits uncozipping uncozipL :: Functor f => Either (f a) (f b) -> f (Either a b) extractL :: Adjunction f u => f a -> a duplicateL :: Adjunction f u => f a -> f (f a) splitL :: Adjunction f u => f a -> (a, f ()) unsplitL :: Functor f => a -> f () -> f a instance Data.Functor.Adjunction.Adjunction ((,) e) ((->) e) instance Data.Functor.Adjunction.Adjunction Data.Functor.Identity.Identity Data.Functor.Identity.Identity instance Data.Functor.Adjunction.Adjunction f g => Data.Functor.Adjunction.Adjunction (Control.Monad.Trans.Identity.IdentityT f) (Control.Monad.Trans.Identity.IdentityT g) instance Data.Functor.Adjunction.Adjunction w m => Data.Functor.Adjunction.Adjunction (Control.Comonad.Trans.Env.EnvT e w) (Control.Monad.Trans.Reader.ReaderT e m) instance Data.Functor.Adjunction.Adjunction m w => Data.Functor.Adjunction.Adjunction (Control.Monad.Trans.Writer.Lazy.WriterT s m) (Control.Comonad.Trans.Traced.TracedT s w) instance (Data.Functor.Adjunction.Adjunction f g, Data.Functor.Adjunction.Adjunction f' g') => Data.Functor.Adjunction.Adjunction (Data.Functor.Compose.Compose f' f) (Data.Functor.Compose.Compose g g') instance (Data.Functor.Adjunction.Adjunction f g, Data.Functor.Adjunction.Adjunction f' g') => Data.Functor.Adjunction.Adjunction (Data.Functor.Sum.Sum f f') (Data.Functor.Product.Product g g') instance Data.Functor.Adjunction.Adjunction f u => Data.Functor.Adjunction.Adjunction (Control.Monad.Free.Free f) (Control.Comonad.Cofree.Cofree u) module Control.Comonad.Trans.Adjoint type Adjoint f g = AdjointT f g Identity runAdjoint :: Functor f => Adjoint f g a -> f (g a) adjoint :: Functor f => f (g a) -> Adjoint f g a newtype AdjointT f g w a AdjointT :: f (w (g a)) -> AdjointT f g w a [runAdjointT] :: AdjointT f g w a -> f (w (g a)) instance (Data.Functor.Adjunction.Adjunction f g, GHC.Base.Functor w) => GHC.Base.Functor (Control.Comonad.Trans.Adjoint.AdjointT f g w) instance (Data.Functor.Adjunction.Adjunction f g, Data.Functor.Extend.Extend w) => Data.Functor.Extend.Extend (Control.Comonad.Trans.Adjoint.AdjointT f g w) instance (Data.Functor.Adjunction.Adjunction f g, Control.Comonad.Comonad w) => Control.Comonad.Comonad (Control.Comonad.Trans.Adjoint.AdjointT f g w) instance (Data.Functor.Adjunction.Adjunction f g, Data.Distributive.Distributive g) => Control.Comonad.Trans.Class.ComonadTrans (Control.Comonad.Trans.Adjoint.AdjointT f g) module Control.Monad.Trans.Adjoint type Adjoint f g = AdjointT f g Identity runAdjoint :: Functor g => Adjoint f g a -> g (f a) adjoint :: Functor g => g (f a) -> Adjoint f g a newtype AdjointT f g m a AdjointT :: g (m (f a)) -> AdjointT f g m a [runAdjointT] :: AdjointT f g m a -> g (m (f a)) instance (Data.Functor.Adjunction.Adjunction f g, GHC.Base.Monad m) => GHC.Base.Functor (Control.Monad.Trans.Adjoint.AdjointT f g m) instance (Data.Functor.Adjunction.Adjunction f g, GHC.Base.Monad m) => GHC.Base.Applicative (Control.Monad.Trans.Adjoint.AdjointT f g m) instance (Data.Functor.Adjunction.Adjunction f g, GHC.Base.Monad m) => GHC.Base.Monad (Control.Monad.Trans.Adjoint.AdjointT f g m) instance (Data.Functor.Adjunction.Adjunction f g, Data.Traversable.Traversable f) => Control.Monad.Trans.Class.MonadTrans (Control.Monad.Trans.Adjoint.AdjointT f g) -- | Representable functors on Hask are all monads, because they are -- isomorphic to a Reader monad. module Control.Monad.Representable.Reader type Reader f = ReaderT f Identity runReader :: Representable f => Reader f b -> Rep f -> b newtype ReaderT f m b ReaderT :: f (m b) -> ReaderT f m b [getReaderT] :: ReaderT f m b -> f (m b) readerT :: Representable f => (Rep f -> m b) -> ReaderT f m b runReaderT :: Representable f => ReaderT f m b -> Rep f -> m b -- | See examples in Control.Monad.Reader. Note, the partially -- applied function type (->) r is a simple reader monad. See -- the instance declaration below. class Monad m => MonadReader r (m :: * -> *) | m -> r -- | Retrieves the monad environment. ask :: MonadReader r m => m r -- | Executes a computation in a modified environment. local :: MonadReader r m => (r -> r) -> m a -> m a -- | Retrieves a function of the current environment. reader :: MonadReader r m => (r -> a) -> m a instance (GHC.Base.Functor f, GHC.Base.Functor m) => GHC.Base.Functor (Control.Monad.Representable.Reader.ReaderT f m) instance (Data.Functor.Rep.Representable f, Data.Functor.Rep.Representable m) => Data.Functor.Rep.Representable (Control.Monad.Representable.Reader.ReaderT f m) instance (Data.Functor.Rep.Representable f, Data.Functor.Bind.Class.Apply m) => Data.Functor.Bind.Class.Apply (Control.Monad.Representable.Reader.ReaderT f m) instance (Data.Functor.Rep.Representable f, GHC.Base.Applicative m) => GHC.Base.Applicative (Control.Monad.Representable.Reader.ReaderT f m) instance (Data.Functor.Rep.Representable f, Data.Functor.Bind.Class.Bind m) => Data.Functor.Bind.Class.Bind (Control.Monad.Representable.Reader.ReaderT f m) instance (Data.Functor.Rep.Representable f, GHC.Base.Monad m) => GHC.Base.Monad (Control.Monad.Representable.Reader.ReaderT f m) instance Data.Functor.Rep.Representable f => Control.Monad.Trans.Class.MonadTrans (Control.Monad.Representable.Reader.ReaderT f) instance (Data.Functor.Rep.Representable f, Data.Distributive.Distributive m) => Data.Distributive.Distributive (Control.Monad.Representable.Reader.ReaderT f m) instance (Data.Functor.Rep.Representable f, Data.Functor.Rep.Representable m, Data.Semigroup.Semigroup (Data.Functor.Rep.Rep f), Data.Semigroup.Semigroup (Data.Functor.Rep.Rep m)) => Data.Functor.Extend.Extend (Control.Monad.Representable.Reader.ReaderT f m) instance (Data.Functor.Rep.Representable f, Data.Functor.Rep.Representable m, GHC.Base.Monoid (Data.Functor.Rep.Rep f), GHC.Base.Monoid (Data.Functor.Rep.Rep m)) => Control.Comonad.Comonad (Control.Monad.Representable.Reader.ReaderT f m) instance (Data.Functor.Rep.Representable f, Control.Monad.IO.Class.MonadIO m) => Control.Monad.IO.Class.MonadIO (Control.Monad.Representable.Reader.ReaderT f m) instance (Data.Functor.Rep.Representable f, Control.Monad.Writer.Class.MonadWriter w m) => Control.Monad.Writer.Class.MonadWriter w (Control.Monad.Representable.Reader.ReaderT f m) instance (Data.Foldable.Foldable f, Data.Foldable.Foldable m) => Data.Foldable.Foldable (Control.Monad.Representable.Reader.ReaderT f m) instance (Data.Semigroup.Foldable.Class.Foldable1 f, Data.Semigroup.Foldable.Class.Foldable1 m) => Data.Semigroup.Foldable.Class.Foldable1 (Control.Monad.Representable.Reader.ReaderT f m) instance (Data.Traversable.Traversable f, Data.Traversable.Traversable m) => Data.Traversable.Traversable (Control.Monad.Representable.Reader.ReaderT f m) instance (Data.Semigroup.Traversable.Class.Traversable1 f, Data.Semigroup.Traversable.Class.Traversable1 m) => Data.Semigroup.Traversable.Class.Traversable1 (Control.Monad.Representable.Reader.ReaderT f m) -- | A generalized State monad, parameterized by a Representable functor. -- The representation of that functor serves as the state. module Control.Monad.Representable.State -- | A memoized state monad parameterized by a representable functor -- g, where the representatation of g, Rep g -- is the state to carry. -- -- The return function leaves the state unchanged, while -- >>= uses the final state of the first computation as -- the initial state of the second. type State g = StateT g Identity -- | Unwrap a state monad computation as a function. (The inverse of -- state.) runState :: Representable g => State g a -> Rep g -> (a, Rep g) -- | Evaluate a state computation with the given initial state and return -- the final value, discarding the final state. -- -- evalState :: Representable g => State g a -> Rep g -> a -- | Evaluate a state computation with the given initial state and return -- the final state, discarding the final value. -- -- execState :: Representable g => State g a -> Rep g -> Rep g -- | Map both the return value and final state of a computation using the -- given function. -- -- mapState :: Functor g => ((a, Rep g) -> (b, Rep g)) -> State g a -> State g b -- | A state transformer monad parameterized by: -- -- -- -- The return function leaves the state unchanged, while -- >>= uses the final state of the first computation as -- the initial state of the second. newtype StateT g m a StateT :: g (m (a, Rep g)) -> StateT g m a [getStateT] :: StateT g m a -> g (m (a, Rep g)) stateT :: Representable g => (Rep g -> m (a, Rep g)) -> StateT g m a runStateT :: Representable g => StateT g m a -> Rep g -> m (a, Rep g) -- | Evaluate a state computation with the given initial state and return -- the final value, discarding the final state. -- -- evalStateT :: (Representable g, Monad m) => StateT g m a -> Rep g -> m a -- | Evaluate a state computation with the given initial state and return -- the final state, discarding the final value. -- -- execStateT :: (Representable g, Monad m) => StateT g m a -> Rep g -> m (Rep g) mapStateT :: Functor g => (m (a, Rep g) -> n (b, Rep g)) -> StateT g m a -> StateT g n b -- | Uniform lifting of a callCC operation to the new monad. This -- version rolls back to the original state on entering the continuation. liftCallCC :: Representable g => ((((a, Rep g) -> m (b, Rep g)) -> m (a, Rep g)) -> m (a, Rep g)) -> ((a -> StateT g m b) -> StateT g m a) -> StateT g m a -- | In-situ lifting of a callCC operation to the new monad. This -- version uses the current state on entering the continuation. It does -- not satisfy the laws of a monad transformer. liftCallCC' :: Representable g => ((((a, Rep g) -> m (b, Rep g)) -> m (a, Rep g)) -> m (a, Rep g)) -> ((a -> StateT g m b) -> StateT g m a) -> StateT g m a -- | Minimal definition is either both of get and put or -- just state class Monad m => MonadState s (m :: * -> *) | m -> s -- | Return the state from the internals of the monad. get :: MonadState s m => m s -- | Replace the state inside the monad. put :: MonadState s m => s -> m () -- | Embed a simple state action into the monad. state :: MonadState s m => (s -> (a, s)) -> m a instance (GHC.Base.Functor g, GHC.Base.Functor m) => GHC.Base.Functor (Control.Monad.Representable.State.StateT g m) instance (Data.Functor.Rep.Representable g, Data.Functor.Bind.Class.Bind m) => Data.Functor.Bind.Class.Apply (Control.Monad.Representable.State.StateT g m) instance (Data.Functor.Rep.Representable g, GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Applicative (Control.Monad.Representable.State.StateT g m) instance (Data.Functor.Rep.Representable g, Data.Functor.Bind.Class.Bind m) => Data.Functor.Bind.Class.Bind (Control.Monad.Representable.State.StateT g m) instance (Data.Functor.Rep.Representable g, GHC.Base.Monad m) => GHC.Base.Monad (Control.Monad.Representable.State.StateT g m) instance Data.Functor.Rep.Representable f => Data.Functor.Bind.Trans.BindTrans (Control.Monad.Representable.State.StateT f) instance Data.Functor.Rep.Representable f => Control.Monad.Trans.Class.MonadTrans (Control.Monad.Representable.State.StateT f) instance (Data.Functor.Rep.Representable g, GHC.Base.Monad m, Data.Functor.Rep.Rep g ~ s) => Control.Monad.State.Class.MonadState s (Control.Monad.Representable.State.StateT g m) instance (Data.Functor.Rep.Representable g, Control.Monad.Reader.Class.MonadReader e m) => Control.Monad.Reader.Class.MonadReader e (Control.Monad.Representable.State.StateT g m) instance (Data.Functor.Rep.Representable g, Control.Monad.Writer.Class.MonadWriter w m) => Control.Monad.Writer.Class.MonadWriter w (Control.Monad.Representable.State.StateT g m) instance (Data.Functor.Rep.Representable g, Control.Monad.Cont.Class.MonadCont m) => Control.Monad.Cont.Class.MonadCont (Control.Monad.Representable.State.StateT g m) instance (GHC.Base.Functor f, Data.Functor.Rep.Representable g, Control.Monad.Free.Class.MonadFree f m) => Control.Monad.Free.Class.MonadFree f (Control.Monad.Representable.State.StateT g m) -- | 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. module Control.Comonad.Representable.Store -- | A memoized store comonad parameterized by a representable functor -- g, where the representatation of g, Rep g -- is the index of the store. type Store g = StoreT g Identity -- | Construct a store comonad computation from a function and a current -- index. (The inverse of runStore.) store :: Representable g => (Rep g -> a) -> Rep g -> Store g a -- | Unwrap a state monad computation as a function. (The inverse of -- state.) runStore :: Representable g => Store g a -> (Rep g -> a, Rep g) -- | A store transformer comonad parameterized by: -- -- data StoreT g w a StoreT :: (w (g a)) -> (Rep g) -> StoreT g w a 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 :: * -> *) | w -> s pos :: ComonadStore s w => w a -> s peek :: ComonadStore s w => s -> w a -> a peeks :: ComonadStore s w => (s -> s) -> w a -> a seek :: ComonadStore s w => s -> w a -> w a seeks :: ComonadStore s w => (s -> s) -> w a -> w a experiment :: (ComonadStore s w, Functor f) => (s -> f s) -> w a -> f a instance (Control.Comonad.Comonad w, Data.Functor.Rep.Representable g, Data.Functor.Rep.Rep g ~ s) => Control.Comonad.Store.Class.ComonadStore s (Control.Comonad.Representable.Store.StoreT g w) instance (GHC.Base.Functor w, GHC.Base.Functor g) => GHC.Base.Functor (Control.Comonad.Representable.Store.StoreT g w) instance (Data.Functor.Bind.Class.Apply w, Data.Semigroup.Semigroup (Data.Functor.Rep.Rep g), Data.Functor.Rep.Representable g) => Data.Functor.Bind.Class.Apply (Control.Comonad.Representable.Store.StoreT g w) instance (Control.Comonad.ComonadApply w, Data.Semigroup.Semigroup (Data.Functor.Rep.Rep g), Data.Functor.Rep.Representable g) => Control.Comonad.ComonadApply (Control.Comonad.Representable.Store.StoreT g w) instance (GHC.Base.Applicative w, GHC.Base.Monoid (Data.Functor.Rep.Rep g), Data.Functor.Rep.Representable g) => GHC.Base.Applicative (Control.Comonad.Representable.Store.StoreT g w) instance (Data.Functor.Extend.Extend w, Data.Functor.Rep.Representable g) => Data.Functor.Extend.Extend (Control.Comonad.Representable.Store.StoreT g w) instance (Control.Comonad.Comonad w, Data.Functor.Rep.Representable g) => Control.Comonad.Comonad (Control.Comonad.Representable.Store.StoreT g w) instance Data.Functor.Rep.Representable g => Control.Comonad.Trans.Class.ComonadTrans (Control.Comonad.Representable.Store.StoreT g) instance Control.Comonad.Hoist.Class.ComonadHoist (Control.Comonad.Representable.Store.StoreT g) instance (Control.Comonad.Traced.Class.ComonadTraced m w, Data.Functor.Rep.Representable g) => Control.Comonad.Traced.Class.ComonadTraced m (Control.Comonad.Representable.Store.StoreT g w) instance (Control.Comonad.Env.Class.ComonadEnv m w, Data.Functor.Rep.Representable g) => Control.Comonad.Env.Class.ComonadEnv m (Control.Comonad.Representable.Store.StoreT g w) instance (Data.Functor.Rep.Representable g, Control.Comonad.Cofree.Class.ComonadCofree f w) => Control.Comonad.Cofree.Class.ComonadCofree f (Control.Comonad.Representable.Store.StoreT g w)