-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Monad transformers and classes -- -- Ether is a Haskell library that extends mtl and -- transformers with tagged monad transformers and classes in a -- compatible way. Introduction https://int-index.github.io/ether/ @package ether @version 0.4.0.2 -- | This module defines the core data type of Ether, TaggedTrans, -- and a bunch of instances for it. TaggedTrans attaches a tag to -- an existing monad transformer. module Control.Monad.Trans.Ether.Tagged -- | Tagged monad transformer. newtype TaggedTrans tag trans (m :: * -> *) a TaggedTrans :: (trans m a) -> TaggedTrans tag trans a -- | Type-restricted coerce. pack :: trans m a -> TaggedTrans tag trans m a -- | Type-restricted coerce. unpack :: TaggedTrans tag trans m a -> trans m a instance GHC.Generics.Constructor Control.Monad.Trans.Ether.Tagged.C1_0TaggedTrans instance GHC.Generics.Datatype Control.Monad.Trans.Ether.Tagged.D1TaggedTrans instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *) (m :: * -> *). Control.Monad.Catch.MonadMask (trans m) => Control.Monad.Catch.MonadMask (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans m) instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *) (m :: * -> *). Control.Monad.Catch.MonadCatch (trans m) => Control.Monad.Catch.MonadCatch (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans m) instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *) (m :: * -> *). Control.Monad.Catch.MonadThrow (trans m) => Control.Monad.Catch.MonadThrow (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans m) instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *). Control.Monad.Morph.MMonad trans => Control.Monad.Morph.MMonad (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans) instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *). Control.Monad.Morph.MFunctor trans => Control.Monad.Morph.MFunctor (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans) instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *) (m :: * -> *). Control.Monad.IO.Class.MonadIO (trans m) => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans m) instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *). Control.Monad.Trans.Class.MonadTrans trans => Control.Monad.Trans.Class.MonadTrans (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans) instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *) (m :: * -> *). Control.Monad.Fix.MonadFix (trans m) => Control.Monad.Fix.MonadFix (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans m) instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *) (m :: * -> *). GHC.Base.MonadPlus (trans m) => GHC.Base.MonadPlus (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans m) instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *) (m :: * -> *). GHC.Base.Monad (trans m) => GHC.Base.Monad (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans m) instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *) (m :: * -> *). GHC.Base.Alternative (trans m) => GHC.Base.Alternative (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans m) instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *) (m :: * -> *). GHC.Base.Applicative (trans m) => GHC.Base.Applicative (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans m) instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *) (m :: * -> *). GHC.Base.Functor (trans m) => GHC.Base.Functor (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans m) instance forall (k :: BOX) (k1 :: BOX) (tag :: k) (trans :: (* -> *) -> k1 -> *) (m :: * -> *) (a :: k1). GHC.Generics.Generic (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans m a) instance forall (k :: BOX) (b :: * -> *) (tag :: k) (trans :: (* -> *) -> * -> *) (m :: * -> *). (Control.Monad.Base.MonadBase b m, Control.Monad.Trans.Class.MonadTrans trans, Control.Ether.Util.MonadApplicative (trans m)) => Control.Monad.Base.MonadBase b (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans m) instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *). Control.Monad.Trans.Control.MonadTransControl trans => Control.Monad.Trans.Control.MonadTransControl (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans) instance forall (k :: BOX) (b :: * -> *) (tag :: k) (trans :: (* -> *) -> * -> *) (m :: * -> *). (Control.Monad.Trans.Control.MonadBaseControl b m, Control.Monad.Trans.Control.MonadTransControl trans, Control.Ether.Util.MonadApplicative (trans m)) => Control.Monad.Trans.Control.MonadBaseControl b (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans m) instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *). Control.Monad.Trans.Lift.Local.LiftLocal trans => Control.Monad.Trans.Lift.Local.LiftLocal (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans) instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *). Control.Monad.Trans.Lift.Catch.LiftCatch trans => Control.Monad.Trans.Lift.Catch.LiftCatch (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans) instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *). Control.Monad.Trans.Lift.Listen.LiftListen trans => Control.Monad.Trans.Lift.Listen.LiftListen (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans) instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *). Control.Monad.Trans.Lift.Pass.LiftPass trans => Control.Monad.Trans.Lift.Pass.LiftPass (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans) instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *). Control.Monad.Trans.Lift.CallCC.LiftCallCC trans => Control.Monad.Trans.Lift.CallCC.LiftCallCC (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans) instance forall (k :: BOX) (tag :: k) (trans :: (* -> *) -> * -> *) (m :: * -> *). (Control.Monad.Cont.Class.MonadCont m, Control.Monad.Trans.Lift.CallCC.LiftCallCC trans, GHC.Base.Monad (trans m)) => Control.Monad.Cont.Class.MonadCont (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans m) instance forall (k :: BOX) r (tag :: k) (trans :: (* -> *) -> * -> *) (m :: * -> *). (Control.Monad.Reader.Class.MonadReader r m, Control.Monad.Trans.Lift.Local.LiftLocal trans, GHC.Base.Monad (trans m)) => Control.Monad.Reader.Class.MonadReader r (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans m) instance forall (k :: BOX) s (tag :: k) (trans :: (* -> *) -> * -> *) (m :: * -> *). (Control.Monad.State.Class.MonadState s m, Control.Monad.Trans.Class.MonadTrans trans, GHC.Base.Monad (trans m)) => Control.Monad.State.Class.MonadState s (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans m) instance forall (k :: BOX) w (tag :: k) (trans :: (* -> *) -> * -> *) (m :: * -> *). (Control.Monad.Writer.Class.MonadWriter w m, Control.Monad.Trans.Lift.Listen.LiftListen trans, Control.Monad.Trans.Lift.Pass.LiftPass trans, GHC.Base.Monad (trans m)) => Control.Monad.Writer.Class.MonadWriter w (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans m) instance forall (k :: BOX) e (tag :: k) (trans :: (* -> *) -> * -> *) (m :: * -> *). (Control.Monad.Error.Class.MonadError e m, Control.Monad.Trans.Lift.Catch.LiftCatch trans, GHC.Base.Monad (trans m)) => Control.Monad.Error.Class.MonadError e (Control.Monad.Trans.Ether.Tagged.TaggedTrans tag trans m) -- | See Control.Monad.Trans.Writer. module Control.Monad.Trans.Ether.Writer -- | The parametrizable writer monad. -- -- Computations can accumulate a monoid value. -- -- The return function produces the output mempty, while -- >>= combines the outputs of the subcomputations using -- mappend. type Writer tag w = WriterT tag w Identity -- | Constructor for computations in the writer monad (the inverse of -- runWriter). writer :: Monad m => proxy tag -> (a, w) -> WriterT tag w m a -- | Runs a Writer and returns both the normal value and the final -- accumulator. runWriter :: proxy tag -> Writer tag w a -> (a, w) -- | Runs a Writer and returns the final accumulator, discarding the -- normal value. execWriter :: proxy tag -> Writer tag w a -> w -- | The writer monad transformer. -- -- The return function produces the output mempty, while -- >>= combines the outputs of the subcomputations using -- mappend. type WriterT tag w = TaggedTrans tag (WriterT w) -- | Constructor for computations in the writer monad transformer. writerT :: proxy tag -> m (a, w) -> WriterT tag w m a -- | Runs a WriterT and returns both the normal value and the final -- accumulator. runWriterT :: proxy tag -> WriterT tag w m a -> m (a, w) -- | Runs a WriterT and returns the final accumulator, discarding -- the normal value. execWriterT :: Monad m => proxy tag -> WriterT tag w m a -> m w -- | Appends a value to the accumulator within the monad. tell :: Monad m => proxy tag -> w -> WriterT tag w m () -- | Executes an action and adds its accumulator to the value of the -- computation. listen :: (Monad m, Monoid w) => proxy tag -> WriterT tag w m a -> WriterT tag w m (a, w) -- | Executes an action which returns a value and a function, and returns -- the value, applying the function to the accumulator. pass :: (Monad m, Monoid w) => proxy tag -> WriterT tag w m (a, w -> w) -> WriterT tag w m a -- | See Control.Monad.Writer.Class. module Control.Monad.Ether.Writer.Class -- | See MonadWriter. class (Monoid w, Monad m) => MonadWriter tag w m | m tag -> w where writer t ~(a, w) = do { tell t w; return a } tell t w = writer t ((), w) -- | Embed a simple writer action. writer :: MonadWriter tag w m => proxy tag -> (a, w) -> m a -- | Append a value to the accumulator within the monad. tell :: MonadWriter tag w m => proxy tag -> w -> m () -- | Execute an action and add its accumulator to the value of the -- computation. listen :: MonadWriter tag w m => proxy tag -> m a -> m (a, w) -- | Execute an action which returns a value and a function, and return the -- value, applying the function to the accumulator. pass :: MonadWriter tag w m => proxy tag -> m (a, w -> w) -> m a -- | Execute an action and add the result of applying the given function to -- its accumulator to the value of the computation. listens :: MonadWriter tag w m => proxy tag -> (w -> b) -> m a -> m (a, b) -- | Execute an action and apply a function to its accumulator. censor :: MonadWriter tag w m => proxy tag -> (w -> w) -> m a -> m a instance forall (k :: BOX) (tag :: k) w w' (m :: * -> *). (GHC.Base.Monoid w, GHC.Base.Monad m, w ~ w') => Control.Monad.Ether.Writer.Class.MonadWriter tag w (Control.Monad.Trans.Ether.Writer.WriterT tag w' m) instance forall (k :: BOX) (tag :: k) w (t :: (* -> *) -> * -> *) (m :: * -> *). (Control.Monad.Trans.Lift.Listen.LiftListen t, Control.Monad.Trans.Lift.Pass.LiftPass t, GHC.Base.Monad (t m), Control.Monad.Ether.Writer.Class.MonadWriter tag w m, GHC.Base.Monoid w) => Control.Monad.Ether.Writer.Class.MonadWriter tag w (t m) -- | See Control.Monad.Writer. module Control.Monad.Ether.Writer -- | See MonadWriter. class (Monoid w, Monad m) => MonadWriter tag w m | m tag -> w where writer t ~(a, w) = do { tell t w; return a } tell t w = writer t ((), w) -- | Embed a simple writer action. writer :: MonadWriter tag w m => proxy tag -> (a, w) -> m a -- | Append a value to the accumulator within the monad. tell :: MonadWriter tag w m => proxy tag -> w -> m () -- | Execute an action and add its accumulator to the value of the -- computation. listen :: MonadWriter tag w m => proxy tag -> m a -> m (a, w) -- | Execute an action which returns a value and a function, and return the -- value, applying the function to the accumulator. pass :: MonadWriter tag w m => proxy tag -> m (a, w -> w) -> m a -- | Execute an action and add the result of applying the given function to -- its accumulator to the value of the computation. listens :: MonadWriter tag w m => proxy tag -> (w -> b) -> m a -> m (a, b) -- | Execute an action and apply a function to its accumulator. censor :: MonadWriter tag w m => proxy tag -> (w -> w) -> m a -> m a -- | The parametrizable writer monad. -- -- Computations can accumulate a monoid value. -- -- The return function produces the output mempty, while -- >>= combines the outputs of the subcomputations using -- mappend. type Writer tag w = WriterT tag w Identity -- | Runs a Writer and returns both the normal value and the final -- accumulator. runWriter :: proxy tag -> Writer tag w a -> (a, w) -- | Runs a Writer and returns the final accumulator, discarding the -- normal value. execWriter :: proxy tag -> Writer tag w a -> w -- | The writer monad transformer. -- -- The return function produces the output mempty, while -- >>= combines the outputs of the subcomputations using -- mappend. type WriterT tag w = TaggedTrans tag (WriterT w) -- | Constructor for computations in the writer monad transformer. writerT :: proxy tag -> m (a, w) -> WriterT tag w m a -- | Runs a WriterT and returns both the normal value and the final -- accumulator. runWriterT :: proxy tag -> WriterT tag w m a -> m (a, w) -- | Runs a WriterT and returns the final accumulator, discarding -- the normal value. execWriterT :: Monad m => proxy tag -> WriterT tag w m a -> m w -- | See Control.Monad.Ether.Writer. module Control.Monad.Ether.Implicit.Writer -- | See MonadWriter. type MonadWriter w = MonadWriter w w -- | See writer. writer :: MonadWriter w m => (a, w) -> m a -- | See tell. tell :: MonadWriter w m => w -> m () -- | See listen. listen :: MonadWriter w m => m a -> m (a, w) -- | See pass. pass :: MonadWriter w m => m (a, w -> w) -> m a -- | See listens. listens :: MonadWriter w m => (w -> b) -> m a -> m (a, b) -- | See censor. censor :: MonadWriter w m => (w -> w) -> m a -> m a -- | See Writer. type Writer w = Writer w w -- | See runWriter. runWriter :: Writer w a -> (a, w) -- | See execWriter. execWriter :: Writer w a -> w -- | See WriterT. type WriterT w = WriterT w w -- | See writerT. writerT :: m (a, w) -> WriterT w m a -- | See runWriterT. runWriterT :: WriterT w m a -> m (a, w) -- | See execWriterT. execWriterT :: Monad m => WriterT w m a -> m w -- | See Control.Monad.Trans.State.Lazy. module Control.Monad.Trans.Ether.State.Lazy -- | The parametrizable state monad. -- -- Computations have access to a mutable state. -- -- 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 tag r = StateT tag r Identity -- | Constructor for computations in the state monad (the inverse of -- runState). state :: Monad m => proxy tag -> (s -> (a, s)) -> StateT tag s m a -- | Runs a State with the given initial state and returns both the -- final value and the final state. runState :: proxy tag -> State tag s a -> s -> (a, s) -- | Runs a State with the given initial state and returns the final -- value, discarding the final state. evalState :: proxy tag -> State tag s a -> s -> a -- | Runs a State with the given initial state and returns the final -- state, discarding the final value. execState :: proxy tag -> State tag s a -> s -> s -- | The state monad transformer. -- -- The return function leaves the state unchanged, while -- >>= uses the final state of the first computation as the -- initial state of the second. type StateT tag s = TaggedTrans tag (StateT s) -- | Constructor for computations in the state monad transformer. stateT :: proxy tag -> (s -> m (a, s)) -> StateT tag s m a -- | Runs a StateT with the given initial state and returns both the -- final value and the final state. runStateT :: proxy tag -> StateT tag s m a -> s -> m (a, s) -- | Runs a StateT with the given initial state and returns the -- final value, discarding the final state. evalStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m a -- | Runs a StateT with the given initial state and returns the -- final state, discarding the final value. execStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m s -- | Fetch the current value of the state within the monad. get :: Monad m => proxy tag -> StateT tag s m s -- | Set the value of the state within the monad. put :: Monad m => proxy tag -> s -> StateT tag s m () -- | See Control.Monad.Trans.State. module Control.Monad.Trans.Ether.State -- | See Control.Monad.Trans.State.Strict. module Control.Monad.Trans.Ether.State.Strict -- | The parametrizable state monad. -- -- Computations have access to a mutable state. -- -- 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 tag r = StateT tag r Identity -- | Constructor for computations in the state monad (the inverse of -- runState). state :: Monad m => proxy tag -> (s -> (a, s)) -> StateT tag s m a -- | Runs a State with the given initial state and returns both the -- final value and the final state. runState :: proxy tag -> State tag s a -> s -> (a, s) -- | Runs a State with the given initial state and returns the final -- value, discarding the final state. evalState :: proxy tag -> State tag s a -> s -> a -- | Runs a State with the given initial state and returns the final -- state, discarding the final value. execState :: proxy tag -> State tag s a -> s -> s -- | The state monad transformer. -- -- The return function leaves the state unchanged, while -- >>= uses the final state of the first computation as the -- initial state of the second. type StateT tag s = TaggedTrans tag (StateT s) -- | Constructor for computations in the state monad transformer. stateT :: proxy tag -> (s -> m (a, s)) -> StateT tag s m a -- | Runs a StateT with the given initial state and returns both the -- final value and the final state. runStateT :: proxy tag -> StateT tag s m a -> s -> m (a, s) -- | Runs a StateT with the given initial state and returns the -- final value, discarding the final state. evalStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m a -- | Runs a StateT with the given initial state and returns the -- final state, discarding the final value. execStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m s -- | Fetch the current value of the state within the monad. get :: Monad m => proxy tag -> StateT tag s m s -- | Set the value of the state within the monad. put :: Monad m => proxy tag -> s -> StateT tag s m () -- | See Control.Monad.State.Class. module Control.Monad.Ether.State.Class -- | See MonadState. class Monad m => MonadState tag s m | m tag -> s where get t = state t (\ s -> (s, s)) put t s = state t (\ _ -> ((), s)) state t f = do { s <- get t; let ~(a, s') = f s; put t s'; return a } -- | Return the state from the internals of the monad. get :: MonadState tag s m => proxy tag -> m s -- | Replace the state inside the monad. put :: MonadState tag s m => proxy tag -> s -> m () -- | Embed a simple state action into the monad. state :: MonadState tag s m => proxy tag -> (s -> (a, s)) -> m a -- | Modifies the state inside a state monad. modify :: MonadState tag s m => proxy tag -> (s -> s) -> m () -- | Gets specific component of the state, using a projection function -- supplied. gets :: MonadState tag s m => proxy tag -> (s -> a) -> m a instance forall (k :: BOX) (tag :: k) s s' (m :: * -> *). (GHC.Base.Monad m, s ~ s') => Control.Monad.Ether.State.Class.MonadState tag s (Control.Monad.Trans.Ether.State.Lazy.StateT tag s' m) instance forall (k :: BOX) (tag :: k) s s' (m :: * -> *). (GHC.Base.Monad m, s ~ s') => Control.Monad.Ether.State.Class.MonadState tag s (Control.Monad.Trans.Ether.State.Strict.StateT tag s' m) instance forall (k :: BOX) (tag :: k) s (t :: (* -> *) -> * -> *) (m :: * -> *). (Control.Monad.Trans.Class.MonadTrans t, GHC.Base.Monad (t m), Control.Monad.Ether.State.Class.MonadState tag s m) => Control.Monad.Ether.State.Class.MonadState tag s (t m) -- | See Control.Monad.State.Lazy. module Control.Monad.Ether.State.Lazy -- | See MonadState. class Monad m => MonadState tag s m | m tag -> s where get t = state t (\ s -> (s, s)) put t s = state t (\ _ -> ((), s)) state t f = do { s <- get t; let ~(a, s') = f s; put t s'; return a } -- | Return the state from the internals of the monad. get :: MonadState tag s m => proxy tag -> m s -- | Replace the state inside the monad. put :: MonadState tag s m => proxy tag -> s -> m () -- | Embed a simple state action into the monad. state :: MonadState tag s m => proxy tag -> (s -> (a, s)) -> m a -- | Modifies the state inside a state monad. modify :: MonadState tag s m => proxy tag -> (s -> s) -> m () -- | Gets specific component of the state, using a projection function -- supplied. gets :: MonadState tag s m => proxy tag -> (s -> a) -> m a -- | The parametrizable state monad. -- -- Computations have access to a mutable state. -- -- 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 tag r = StateT tag r Identity -- | Runs a State with the given initial state and returns both the -- final value and the final state. runState :: proxy tag -> State tag s a -> s -> (a, s) -- | Runs a State with the given initial state and returns the final -- value, discarding the final state. evalState :: proxy tag -> State tag s a -> s -> a -- | Runs a State with the given initial state and returns the final -- state, discarding the final value. execState :: proxy tag -> State tag s a -> s -> s -- | The state monad transformer. -- -- The return function leaves the state unchanged, while -- >>= uses the final state of the first computation as the -- initial state of the second. type StateT tag s = TaggedTrans tag (StateT s) -- | Constructor for computations in the state monad transformer. stateT :: proxy tag -> (s -> m (a, s)) -> StateT tag s m a -- | Runs a StateT with the given initial state and returns both the -- final value and the final state. runStateT :: proxy tag -> StateT tag s m a -> s -> m (a, s) -- | Runs a StateT with the given initial state and returns the -- final value, discarding the final state. evalStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m a -- | Runs a StateT with the given initial state and returns the -- final state, discarding the final value. execStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m s -- | See Control.Monad.State. module Control.Monad.Ether.State -- | See Control.Monad.Ether.State.Lazy. module Control.Monad.Ether.Implicit.State.Lazy -- | See MonadState. type MonadState s = MonadState s s -- | See get. get :: MonadState s m => m s -- | See put. put :: MonadState s m => s -> m () -- | See state. state :: MonadState s m => (s -> (a, s)) -> m a -- | See modify. modify :: MonadState s m => (s -> s) -> m () -- | See gets. gets :: MonadState s m => (s -> a) -> m a -- | See State. type State s = State s s -- | See runState. runState :: State s a -> s -> (a, s) -- | See evalState. evalState :: State s a -> s -> a -- | See execState. execState :: State s a -> s -> s -- | See StateT. type StateT s = StateT s s -- | See stateT. stateT :: (s -> m (a, s)) -> StateT s m a -- | See runStateT. runStateT :: StateT s m a -> s -> m (a, s) -- | See evalStateT. evalStateT :: Monad m => StateT s m a -> s -> m a -- | See execStateT. execStateT :: Monad m => StateT s m a -> s -> m s -- | See Control.Monad.Ether.State. module Control.Monad.Ether.Implicit.State -- | See Control.Monad.State.Strict. module Control.Monad.Ether.State.Strict -- | See MonadState. class Monad m => MonadState tag s m | m tag -> s where get t = state t (\ s -> (s, s)) put t s = state t (\ _ -> ((), s)) state t f = do { s <- get t; let ~(a, s') = f s; put t s'; return a } -- | Return the state from the internals of the monad. get :: MonadState tag s m => proxy tag -> m s -- | Replace the state inside the monad. put :: MonadState tag s m => proxy tag -> s -> m () -- | Embed a simple state action into the monad. state :: MonadState tag s m => proxy tag -> (s -> (a, s)) -> m a -- | Modifies the state inside a state monad. modify :: MonadState tag s m => proxy tag -> (s -> s) -> m () -- | Gets specific component of the state, using a projection function -- supplied. gets :: MonadState tag s m => proxy tag -> (s -> a) -> m a -- | The parametrizable state monad. -- -- Computations have access to a mutable state. -- -- 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 tag r = StateT tag r Identity -- | Runs a State with the given initial state and returns both the -- final value and the final state. runState :: proxy tag -> State tag s a -> s -> (a, s) -- | Runs a State with the given initial state and returns the final -- value, discarding the final state. evalState :: proxy tag -> State tag s a -> s -> a -- | Runs a State with the given initial state and returns the final -- state, discarding the final value. execState :: proxy tag -> State tag s a -> s -> s -- | The state monad transformer. -- -- The return function leaves the state unchanged, while -- >>= uses the final state of the first computation as the -- initial state of the second. type StateT tag s = TaggedTrans tag (StateT s) -- | Constructor for computations in the state monad transformer. stateT :: proxy tag -> (s -> m (a, s)) -> StateT tag s m a -- | Runs a StateT with the given initial state and returns both the -- final value and the final state. runStateT :: proxy tag -> StateT tag s m a -> s -> m (a, s) -- | Runs a StateT with the given initial state and returns the -- final value, discarding the final state. evalStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m a -- | Runs a StateT with the given initial state and returns the -- final state, discarding the final value. execStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m s -- | See Control.Monad.Ether.State.Strict. module Control.Monad.Ether.Implicit.State.Strict -- | See MonadState. type MonadState s = MonadState s s -- | See get. get :: MonadState s m => m s -- | See put. put :: MonadState s m => s -> m () -- | See state. state :: MonadState s m => (s -> (a, s)) -> m a -- | See modify. modify :: MonadState s m => (s -> s) -> m () -- | See gets. gets :: MonadState s m => (s -> a) -> m a -- | See State. type State s = State s s -- | See runState. runState :: State s a -> s -> (a, s) -- | See evalState. evalState :: State s a -> s -> a -- | See execState. execState :: State s a -> s -> s -- | See StateT. type StateT s = StateT s s -- | See stateT. stateT :: (s -> m (a, s)) -> StateT s m a -- | See runStateT. runStateT :: StateT s m a -> s -> m (a, s) -- | See evalStateT. evalStateT :: Monad m => StateT s m a -> s -> m a -- | See execStateT. execStateT :: Monad m => StateT s m a -> s -> m s -- | See Control.Monad.Trans.Except. module Control.Monad.Trans.Ether.Except -- | The parameterizable exception monad. -- -- Computations are either exceptions or normal values. -- -- The return function returns a normal value, while -- >>= exits on the first exception. type Except tag e = ExceptT tag e Identity -- | Constructor for computations in the exception monad (the inverse of -- runExcept). except :: Monad m => proxy tag -> Either e a -> ExceptT tag e m a -- | Runs an Except and returns either an exception or a normal -- value. runExcept :: proxy tag -> Except tag e a -> Either e a -- | The exception monad transformer. -- -- The return function returns a normal value, while -- >>= exits on the first exception. type ExceptT tag e = TaggedTrans tag (ExceptT e) -- | Constructor for computations in the exception monad transformer. exceptT :: proxy tag -> m (Either e a) -> ExceptT tag e m a -- | Runs an ExceptT and returns either an exception or a normal -- value. runExceptT :: proxy tag -> ExceptT tag e m a -> m (Either e a) -- | Is used within a monadic computation to begin exception processing. throw :: Monad m => proxy tag -> e -> ExceptT tag e m a -- | A handler function to handle previous exceptions and return to normal -- execution. catch :: Monad m => proxy tag -> ExceptT tag e m a -> (e -> ExceptT tag e m a) -> ExceptT tag e m a -- | See Control.Monad.Except. module Control.Monad.Ether.Except.Class -- | See MonadError. class Monad m => MonadExcept tag e m | m tag -> e -- | Is used within a monadic computation to begin exception processing. throw :: MonadExcept tag e m => proxy tag -> e -> m a -- | A handler function to handle previous exceptions and return to normal -- execution. catch :: MonadExcept tag e m => proxy tag -> m a -> (e -> m a) -> m a instance forall (k :: BOX) (tag :: k) e e' (m :: * -> *). (GHC.Base.Monad m, e ~ e') => Control.Monad.Ether.Except.Class.MonadExcept tag e (Control.Monad.Trans.Ether.Except.ExceptT tag e' m) instance forall (k :: BOX) (tag :: k) e (t :: (* -> *) -> * -> *) (m :: * -> *). (Control.Monad.Trans.Lift.Catch.LiftCatch t, GHC.Base.Monad (t m), Control.Monad.Ether.Except.Class.MonadExcept tag e m) => Control.Monad.Ether.Except.Class.MonadExcept tag e (t m) -- | See Control.Monad.Except. module Control.Monad.Ether.Except -- | See MonadError. class Monad m => MonadExcept tag e m | m tag -> e -- | Is used within a monadic computation to begin exception processing. throw :: MonadExcept tag e m => proxy tag -> e -> m a -- | A handler function to handle previous exceptions and return to normal -- execution. catch :: MonadExcept tag e m => proxy tag -> m a -> (e -> m a) -> m a -- | The parameterizable exception monad. -- -- Computations are either exceptions or normal values. -- -- The return function returns a normal value, while -- >>= exits on the first exception. type Except tag e = ExceptT tag e Identity -- | Runs an Except and returns either an exception or a normal -- value. runExcept :: proxy tag -> Except tag e a -> Either e a -- | The exception monad transformer. -- -- The return function returns a normal value, while -- >>= exits on the first exception. type ExceptT tag e = TaggedTrans tag (ExceptT e) -- | Constructor for computations in the exception monad transformer. exceptT :: proxy tag -> m (Either e a) -> ExceptT tag e m a -- | Runs an ExceptT and returns either an exception or a normal -- value. runExceptT :: proxy tag -> ExceptT tag e m a -> m (Either e a) -- | Runs an ExceptT and handles the exception with the given -- function. handleT :: Functor m => proxy tag -> (e -> a) -> ExceptT tag e m a -> m a -- | Runs an Except and handles the exception with the given -- function. handle :: proxy tag -> (e -> a) -> Except tag e a -> a -- | See Control.Monad.Ether.Except. module Control.Monad.Ether.Implicit.Except -- | See MonadExcept. type MonadExcept e = MonadExcept e e -- | See throw. throw :: MonadExcept e m => e -> m a -- | See catch. catch :: MonadExcept e m => m a -> (e -> m a) -> m a -- | See Except. type Except e = Except e e -- | See runExcept. runExcept :: Except e a -> Either e a -- | See ExceptT. type ExceptT e = ExceptT e e -- | See exceptT. exceptT :: m (Either e a) -> ExceptT e m a -- | See runExceptT. runExceptT :: ExceptT e m a -> m (Either e a) -- | See handle. handle :: (e -> a) -> Except e a -> a -- | See handleT. handleT :: Functor m => (e -> a) -> ExceptT e m a -> m a -- | See Control.Monad.Trans.Reader. module Control.Monad.Trans.Ether.Reader -- | The parameterizable reader monad. -- -- Computations are functions of a shared environment. -- -- The return function ignores the environment, while -- >>= passes the inherited environment to both -- subcomputations. type Reader tag r = ReaderT tag r Identity -- | Constructor for computations in the reader monad (the inverse of -- runReader). reader :: Monad m => proxy tag -> (r -> a) -> ReaderT tag r m a -- | Runs a ReaderT with the given environment and returns the final -- value. runReader :: proxy tag -> Reader tag r a -> r -> a -- | The reader monad transformer, which adds a read-only environment to -- the given monad. -- -- The return function ignores the environment, while -- >>= passes the inherited environment to both -- subcomputations. type ReaderT tag r = TaggedTrans tag (ReaderT r) -- | Constructor for computations in the reader monad transformer. readerT :: proxy tag -> (r -> m a) -> ReaderT tag r m a -- | Runs a ReaderT with the given environment and returns the final -- value. runReaderT :: proxy tag -> ReaderT tag r m a -> r -> m a -- | Fetch the value of the environment. ask :: Monad m => proxy tag -> ReaderT tag r m r -- | Execute a computation in a modified environment (a specialization of -- withReaderT). -- -- local :: proxy tag -> (r -> r) -> ReaderT tag r m a -> ReaderT tag r m a -- | See Control.Monad.Reader.Class. module Control.Monad.Ether.Reader.Class -- | See MonadReader. class Monad m => MonadReader tag r m | m tag -> r where ask t = reader t id reader t f = fmap f (ask t) -- | Retrieves the monad environment. ask :: MonadReader tag r m => proxy tag -> m r -- | Executes a computation in a modified environment. local :: MonadReader tag r m => proxy tag -> (r -> r) -> m a -> m a -- | Retrieves a function of the current environment. reader :: MonadReader tag r m => proxy tag -> (r -> a) -> m a -- | Retrieves a function of the current environment. asks :: MonadReader tag r m => proxy tag -> (r -> a) -> m a instance forall (k :: BOX) (tag :: k) r r' (m :: * -> *). (GHC.Base.Monad m, r ~ r') => Control.Monad.Ether.Reader.Class.MonadReader tag r (Control.Monad.Trans.Ether.Reader.ReaderT tag r' m) instance forall (k :: BOX) (tag :: k) r (t :: (* -> *) -> * -> *) (m :: * -> *). (Control.Monad.Trans.Lift.Local.LiftLocal t, GHC.Base.Monad (t m), Control.Monad.Ether.Reader.Class.MonadReader tag r m) => Control.Monad.Ether.Reader.Class.MonadReader tag r (t m) -- | Type-level machinery to manipulate constraints on the monad -- transformer stack. -- -- Out of the box it provides the following dispatch strategies: -- -- -- --
--   import qualified Control.Monad.State as T
--   import Control.Ether.TH (ethereal)
--   import Control.Monad.Ether.State (MonadState)
--   import Control.Monad.Trans.Ether.Dispatch (tagAttach, tagDispatch)
--   
--   ethereal "Foo" "foo"
--   ethereal "Bar" "bar"
--   
--   f :: T.MonadState Int m => m String
--   f = fmap show T.get
--   
--   g :: MonadState Foo Int m => m String
--   g = tagAttach foo f
--   
--   h :: MonadState Bar Int m => m String
--   h = tagReplace foo bar g
--   
module Control.Monad.Trans.Ether.Dispatch -- | Wrap a monad to change its tags. Under the hood this is simply -- IdentityT, all the work is happening on the type level. data DispatchT dp m a -- | Encode type-level information for tagAttach. data K_TagAttach t TagAttach :: t -> K_TagAttach t -- | Encode type-level information for tagReplace. data K_TagReplace tOld tNew TagReplace :: tOld -> tNew -> K_TagReplace tOld tNew -- | Attach a tag to untagged transformers. tagAttach :: proxy t -> DispatchTagAttachT t m a -> m a -- | Replace a tag with another tag. tagReplace :: proxy tOld -> proxy tNew -> DispatchTagReplaceT tOld tNew m a -> m a instance GHC.Generics.Constructor Control.Monad.Trans.Ether.Dispatch.C1_0DispatchT instance GHC.Generics.Datatype Control.Monad.Trans.Ether.Dispatch.D1DispatchT instance forall (k :: BOX) (dp :: k) (m :: * -> *). Control.Monad.Catch.MonadMask m => Control.Monad.Catch.MonadMask (Control.Monad.Trans.Ether.Dispatch.DispatchT dp m) instance forall (k :: BOX) (dp :: k) (m :: * -> *). Control.Monad.Catch.MonadCatch m => Control.Monad.Catch.MonadCatch (Control.Monad.Trans.Ether.Dispatch.DispatchT dp m) instance forall (k :: BOX) (dp :: k) (m :: * -> *). Control.Monad.Catch.MonadThrow m => Control.Monad.Catch.MonadThrow (Control.Monad.Trans.Ether.Dispatch.DispatchT dp m) instance forall (k :: BOX) (dp :: k). Control.Monad.Morph.MMonad (Control.Monad.Trans.Ether.Dispatch.DispatchT dp) instance forall (k :: BOX) (dp :: k). Control.Monad.Morph.MFunctor (Control.Monad.Trans.Ether.Dispatch.DispatchT dp) instance forall (k :: BOX) (dp :: k) (m :: * -> *). Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.Ether.Dispatch.DispatchT dp m) instance forall (k :: BOX) (dp :: k). Control.Monad.Trans.Class.MonadTrans (Control.Monad.Trans.Ether.Dispatch.DispatchT dp) instance forall (k :: BOX) (dp :: k) (m :: * -> *). Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (Control.Monad.Trans.Ether.Dispatch.DispatchT dp m) instance forall (k :: BOX) (dp :: k) (m :: * -> *). GHC.Base.MonadPlus m => GHC.Base.MonadPlus (Control.Monad.Trans.Ether.Dispatch.DispatchT dp m) instance forall (k :: BOX) (dp :: k) (m :: * -> *). GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Trans.Ether.Dispatch.DispatchT dp m) instance forall (k :: BOX) (dp :: k) (m :: * -> *). GHC.Base.Alternative m => GHC.Base.Alternative (Control.Monad.Trans.Ether.Dispatch.DispatchT dp m) instance forall (k :: BOX) (dp :: k) (m :: * -> *). GHC.Base.Applicative m => GHC.Base.Applicative (Control.Monad.Trans.Ether.Dispatch.DispatchT dp m) instance forall (k :: BOX) (dp :: k) (m :: * -> *). GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.Ether.Dispatch.DispatchT dp m) instance forall (k :: BOX) (dp :: k) (m :: * -> *) a. GHC.Generics.Generic (Control.Monad.Trans.Ether.Dispatch.DispatchT dp m a) instance forall (k :: BOX) (b :: * -> *) (dp :: k) (m :: * -> *). Control.Monad.Base.MonadBase b m => Control.Monad.Base.MonadBase b (Control.Monad.Trans.Ether.Dispatch.DispatchT dp m) instance forall (k :: BOX) (dp :: k). Control.Monad.Trans.Control.MonadTransControl (Control.Monad.Trans.Ether.Dispatch.DispatchT dp) instance forall (k :: BOX) (b :: * -> *) (dp :: k) (m :: * -> *). Control.Monad.Trans.Control.MonadBaseControl b m => Control.Monad.Trans.Control.MonadBaseControl b (Control.Monad.Trans.Ether.Dispatch.DispatchT dp m) instance forall (k :: BOX) (dp :: k). Control.Monad.Trans.Lift.Local.LiftLocal (Control.Monad.Trans.Ether.Dispatch.DispatchT dp) instance forall (k :: BOX) (dp :: k). Control.Monad.Trans.Lift.Catch.LiftCatch (Control.Monad.Trans.Ether.Dispatch.DispatchT dp) instance forall (k :: BOX) (dp :: k). Control.Monad.Trans.Lift.Listen.LiftListen (Control.Monad.Trans.Ether.Dispatch.DispatchT dp) instance forall (k :: BOX) (dp :: k). Control.Monad.Trans.Lift.Pass.LiftPass (Control.Monad.Trans.Ether.Dispatch.DispatchT dp) instance forall (k :: BOX) (dp :: k). Control.Monad.Trans.Lift.CallCC.LiftCallCC (Control.Monad.Trans.Ether.Dispatch.DispatchT dp) instance forall (k :: BOX) r (tag :: k) (m :: * -> *). Control.Monad.Ether.Reader.Class.MonadReader tag r m => Control.Monad.Reader.Class.MonadReader r (Control.Monad.Trans.Ether.Dispatch.DispatchTagAttachT tag m) instance forall (k :: BOX) s (tag :: k) (m :: * -> *). Control.Monad.Ether.State.Class.MonadState tag s m => Control.Monad.State.Class.MonadState s (Control.Monad.Trans.Ether.Dispatch.DispatchTagAttachT tag m) instance forall (k :: BOX) e (tag :: k) (m :: * -> *). Control.Monad.Ether.Except.Class.MonadExcept tag e m => Control.Monad.Error.Class.MonadError e (Control.Monad.Trans.Ether.Dispatch.DispatchTagAttachT tag m) instance forall (k :: BOX) w (tag :: k) (m :: * -> *). Control.Monad.Ether.Writer.Class.MonadWriter tag w m => Control.Monad.Writer.Class.MonadWriter w (Control.Monad.Trans.Ether.Dispatch.DispatchTagAttachT tag m) instance forall (k :: BOX) (k1 :: BOX) (tOld :: k) r (tNew :: k1) (m :: * -> *). Control.Monad.Ether.Reader.Class.MonadReader tNew r m => Control.Monad.Ether.Reader.Class.MonadReader tOld r (Control.Monad.Trans.Ether.Dispatch.DispatchTagReplaceT tOld tNew m) instance forall (k :: BOX) (k1 :: BOX) (tOld :: k) s (tNew :: k1) (m :: * -> *). Control.Monad.Ether.State.Class.MonadState tNew s m => Control.Monad.Ether.State.Class.MonadState tOld s (Control.Monad.Trans.Ether.Dispatch.DispatchTagReplaceT tOld tNew m) instance forall (k :: BOX) (k1 :: BOX) (tOld :: k) e (tNew :: k1) (m :: * -> *). Control.Monad.Ether.Except.Class.MonadExcept tNew e m => Control.Monad.Ether.Except.Class.MonadExcept tOld e (Control.Monad.Trans.Ether.Dispatch.DispatchTagReplaceT tOld tNew m) instance forall (k :: BOX) (k1 :: BOX) (tOld :: k) w (tNew :: k1) (m :: * -> *). Control.Monad.Ether.Writer.Class.MonadWriter tNew w m => Control.Monad.Ether.Writer.Class.MonadWriter tOld w (Control.Monad.Trans.Ether.Dispatch.DispatchTagReplaceT tOld tNew m) -- | See Control.Monad.Reader. module Control.Monad.Ether.Reader -- | See MonadReader. class Monad m => MonadReader tag r m | m tag -> r where ask t = reader t id reader t f = fmap f (ask t) -- | Retrieves the monad environment. ask :: MonadReader tag r m => proxy tag -> m r -- | Executes a computation in a modified environment. local :: MonadReader tag r m => proxy tag -> (r -> r) -> m a -> m a -- | Retrieves a function of the current environment. reader :: MonadReader tag r m => proxy tag -> (r -> a) -> m a -- | Retrieves a function of the current environment. asks :: MonadReader tag r m => proxy tag -> (r -> a) -> m a -- | The parameterizable reader monad. -- -- Computations are functions of a shared environment. -- -- The return function ignores the environment, while -- >>= passes the inherited environment to both -- subcomputations. type Reader tag r = ReaderT tag r Identity -- | Runs a ReaderT with the given environment and returns the final -- value. runReader :: proxy tag -> Reader tag r a -> r -> a -- | The reader monad transformer, which adds a read-only environment to -- the given monad. -- -- The return function ignores the environment, while -- >>= passes the inherited environment to both -- subcomputations. type ReaderT tag r = TaggedTrans tag (ReaderT r) -- | Constructor for computations in the reader monad transformer. readerT :: proxy tag -> (r -> m a) -> ReaderT tag r m a -- | Runs a ReaderT with the given environment and returns the final -- value. runReaderT :: proxy tag -> ReaderT tag r m a -> r -> m a -- | See Control.Monad.Ether.Reader. module Control.Monad.Ether.Implicit.Reader -- | See MonadReader. type MonadReader r = MonadReader r r -- | See local. local :: MonadReader r m => (r -> r) -> m a -> m a -- | See ask. ask :: MonadReader r m => m r -- | See reader. reader :: MonadReader r m => (r -> a) -> m a -- | See asks. asks :: MonadReader r m => (r -> a) -> m a -- | See Reader. type Reader r = Reader r r -- | See runReader. runReader :: Reader r a -> r -> a -- | See ReaderT. type ReaderT r = ReaderT r r -- | See readerT. readerT :: (r -> m a) -> ReaderT r m a -- | See runReaderT. runReaderT :: ReaderT r m a -> r -> m a -- | Template Haskell utilities. module Control.Ether.TH -- | Creates a tag and a value-level proxy for it. -- -- ethereal "Foo" "foo" generates the following code: -- --
--   data Foo
--   foo :: Proxy Foo
--   foo = Proxy
--   
ethereal :: String -> String -> DecsQ -- | This module provides convenience exports of all implicitly tagged -- monad classes from Ether. module Control.Monad.Ether.Implicit -- | This module provides convenience exports of all tagged monad classes -- from Ether. module Control.Monad.Ether -- | Abbreviations for constraints. module Control.Ether.Abbr -- | Denotes MonadReader. The mnemonic is that you read values of -- type r from the reader environment tagged by tag, -- thus the arrows points from tag to r. data (-->) tag r -- | Denotes MonadWriter. The mnemonic is that you write values of -- type w to the writer accumulator tagged by tag, thus -- the arrows points from w to tag. data (<--) tag w -- | Denotes MonadState. The mnemonic is that you can both read from -- and write into the state, thus the arrow points in both directions. data (<->) tag s -- | Denotes MonadExcept. data (-!-) tag e -- | Reify a list of constraint abbreviations. -- --
--   f :: Ether '[Foo --> r, Bar <-- w, Baz <-> s, Quux -!- e] m => m a
--   
-- -- expands into -- --
--   f :: ( MonadReader Foo  r m
--        , MonadWriter Bar  w m
--        , MonadState  Baz  s m
--        , MonadExcept Quux e m
--        ) => m a
--   
-- | Turns an abbreviation into an actual constraint. -- | See Control.Ether.Abbr. module Control.Ether.Implicit.Abbr -- | Denotes MonadReader. data R r -- | Denotes MonadWriter. data W w -- | Denotes MonadState. data S s -- | Denotes MonadExcept. data E e