-- 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.5.1.0 module Ether.TaggedTrans newtype TaggedTrans tag trans m a TaggedTrans :: (trans m a) -> TaggedTrans tag trans m a instance forall k (tag :: k) k1 (trans :: k1 -> * -> *) (m :: k1). Control.Monad.Catch.MonadMask (trans m) => Control.Monad.Catch.MonadMask (Ether.TaggedTrans.TaggedTrans tag trans m) instance forall k (tag :: k) k1 (trans :: k1 -> * -> *) (m :: k1). Control.Monad.Catch.MonadCatch (trans m) => Control.Monad.Catch.MonadCatch (Ether.TaggedTrans.TaggedTrans tag trans m) instance forall k (tag :: k) k1 (trans :: k1 -> * -> *) (m :: k1). Control.Monad.Catch.MonadThrow (trans m) => Control.Monad.Catch.MonadThrow (Ether.TaggedTrans.TaggedTrans tag trans m) instance forall k (tag :: k) k1 (trans :: k1 -> * -> *) (m :: k1). Control.Monad.IO.Class.MonadIO (trans m) => Control.Monad.IO.Class.MonadIO (Ether.TaggedTrans.TaggedTrans tag trans m) instance forall k (tag :: k) (trans :: (* -> *) -> * -> *). Control.Monad.Trans.Class.MonadTrans trans => Control.Monad.Trans.Class.MonadTrans (Ether.TaggedTrans.TaggedTrans tag trans) instance forall k (tag :: k) k1 (trans :: k1 -> * -> *) (m :: k1). Control.Monad.Fix.MonadFix (trans m) => Control.Monad.Fix.MonadFix (Ether.TaggedTrans.TaggedTrans tag trans m) instance forall k (tag :: k) k1 (trans :: k1 -> * -> *) (m :: k1). GHC.Base.MonadPlus (trans m) => GHC.Base.MonadPlus (Ether.TaggedTrans.TaggedTrans tag trans m) instance forall k (tag :: k) k1 (trans :: k1 -> * -> *) (m :: k1). GHC.Base.Monad (trans m) => GHC.Base.Monad (Ether.TaggedTrans.TaggedTrans tag trans m) instance forall k (tag :: k) k1 (trans :: k1 -> * -> *) (m :: k1). GHC.Base.Alternative (trans m) => GHC.Base.Alternative (Ether.TaggedTrans.TaggedTrans tag trans m) instance forall k (tag :: k) k1 (trans :: k1 -> * -> *) (m :: k1). GHC.Base.Applicative (trans m) => GHC.Base.Applicative (Ether.TaggedTrans.TaggedTrans tag trans m) instance forall k (tag :: k) k1 (trans :: k1 -> * -> *) (m :: k1). GHC.Base.Functor (trans m) => GHC.Base.Functor (Ether.TaggedTrans.TaggedTrans tag trans m) instance forall k (tag :: k) k1 k2 (trans :: k1 -> k2 -> *) (m :: k1) (a :: k2). GHC.Generics.Generic (Ether.TaggedTrans.TaggedTrans tag trans m a) instance forall k k1 (b :: * -> *) (trans :: k1 -> * -> *) (m :: k1) (tag :: k). Control.Monad.Base.MonadBase b (trans m) => Control.Monad.Base.MonadBase b (Ether.TaggedTrans.TaggedTrans tag trans m) instance forall k (trans :: (* -> *) -> * -> *) (tag :: k). Control.Monad.Trans.Control.MonadTransControl trans => Control.Monad.Trans.Control.MonadTransControl (Ether.TaggedTrans.TaggedTrans tag trans) instance forall k k1 (b :: * -> *) (trans :: k1 -> * -> *) (m :: k1) (tag :: k). Control.Monad.Trans.Control.MonadBaseControl b (trans m) => Control.Monad.Trans.Control.MonadBaseControl b (Ether.TaggedTrans.TaggedTrans tag trans m) instance forall k (trans :: (* -> *) -> * -> *) (tag :: k). Control.Monad.Trans.Lift.Local.LiftLocal trans => Control.Monad.Trans.Lift.Local.LiftLocal (Ether.TaggedTrans.TaggedTrans tag trans) instance forall k (trans :: (* -> *) -> * -> *) (tag :: k). Control.Monad.Trans.Lift.Catch.LiftCatch trans => Control.Monad.Trans.Lift.Catch.LiftCatch (Ether.TaggedTrans.TaggedTrans tag trans) instance forall k (trans :: (* -> *) -> * -> *) (tag :: k). Control.Monad.Trans.Lift.Listen.LiftListen trans => Control.Monad.Trans.Lift.Listen.LiftListen (Ether.TaggedTrans.TaggedTrans tag trans) instance forall k (trans :: (* -> *) -> * -> *) (tag :: k). Control.Monad.Trans.Lift.Pass.LiftPass trans => Control.Monad.Trans.Lift.Pass.LiftPass (Ether.TaggedTrans.TaggedTrans tag trans) instance forall k (trans :: (* -> *) -> * -> *) (tag :: k). Control.Monad.Trans.Lift.CallCC.LiftCallCC trans => Control.Monad.Trans.Lift.CallCC.LiftCallCC (Ether.TaggedTrans.TaggedTrans tag trans) instance forall k (m :: * -> *) (trans :: (* -> *) -> * -> *) (tag :: k). (Control.Monad.Cont.Class.MonadCont m, Control.Monad.Trans.Lift.CallCC.LiftCallCC trans, GHC.Base.Monad (trans m)) => Control.Monad.Cont.Class.MonadCont (Ether.TaggedTrans.TaggedTrans tag trans m) instance forall k r (m :: * -> *) (trans :: (* -> *) -> * -> *) (tag :: k). (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 (Ether.TaggedTrans.TaggedTrans tag trans m) instance forall k s (m :: * -> *) (trans :: (* -> *) -> * -> *) (tag :: k). (Control.Monad.State.Class.MonadState s m, Control.Monad.Trans.Class.MonadTrans trans, GHC.Base.Monad (trans m)) => Control.Monad.State.Class.MonadState s (Ether.TaggedTrans.TaggedTrans tag trans m) instance forall k w (m :: * -> *) (trans :: (* -> *) -> * -> *) (tag :: k). (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 (Ether.TaggedTrans.TaggedTrans tag trans m) instance forall k e (m :: * -> *) (trans :: (* -> *) -> * -> *) (tag :: k). (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 (Ether.TaggedTrans.TaggedTrans tag trans m) instance forall k k1 (trans :: (* -> *) -> k1 -> *) (tag :: k). Control.Monad.Morph.MFunctor trans => Control.Monad.Morph.MFunctor (Ether.TaggedTrans.TaggedTrans tag trans) instance forall k (trans :: (* -> *) -> * -> *) (tag :: k). Control.Monad.Morph.MMonad trans => Control.Monad.Morph.MMonad (Ether.TaggedTrans.TaggedTrans tag trans) module Ether.Internal -- | A Tagged s b value is a value b with an -- attached phantom type s. This can be used in place of the -- more traditional but less safe idiom of passing in an undefined value -- with the type, because unlike an (s -> b), a -- Tagged s b can't try to use the argument s as -- a real value. -- -- Moreover, you don't have to rely on the compiler to inline away the -- extra argument, because the newtype is "free" -- -- Tagged has kind k -> * -> * if the compiler -- supports PolyKinds, therefore there is an extra k -- showing in the instance haddocks that may cause confusion. newtype Tagged k (s :: k) b :: forall k. k -> * -> * Tagged :: b -> Tagged k b [unTagged] :: Tagged k b -> b class HasLens tag outer inner | tag outer -> inner lensOf :: HasLens tag outer inner => Lens' outer inner type LensLike f s t a b = (a -> f b) -> s -> f t type Lens s t a b = forall f. Functor f => LensLike f s t a b type Lens' s a = Lens s s a a newtype ReifiedLens s t a b Lens :: (Lens s t a b) -> ReifiedLens s t a b type ReifiedLens' s a = ReifiedLens s s a a view :: LensLike (Const a) s t a b -> s -> a over :: LensLike Identity s t a b -> (a -> b) -> s -> t data HList xs [HNil] :: HList '[] [HCons] :: x -> HList xs -> HList (x : xs) type KindOf (a :: k) = k data TAGGED e t class HandleSuper eff p trans => Handle eff p (trans :: K_Trans) | eff trans -> p handling :: (Handle eff p trans, Monad m) => (HandleConstraint eff p trans m => r) -> r makeTupleInstancesHasLens :: [Int] -> DecsQ module Ether.Reader class Monad m => MonadReader tag r m | m tag -> r where ask = reader @tag id reader f = fmap f (ask @tag) -- | Retrieves the monad environment. ask :: MonadReader tag r m => m r -- | Executes a computation in a modified environment. local :: MonadReader tag r m => (r -> r) -> m a -> m a -- | Retrieves a function of the current environment. reader :: MonadReader tag r m => (r -> a) -> m a -- | Retrieves the monad environment. ask :: MonadReader tag r m => m r -- | Executes a computation in a modified environment. local :: MonadReader tag r m => (r -> r) -> m a -> m a -- | Retrieves a function of the current environment. reader :: MonadReader tag r m => (r -> a) -> m a -- | Retrieves a function of the current environment. asks :: forall tag r m a. MonadReader tag r m => (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 :: forall tag r a. 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 (TAGGED READER tag) (ReaderT r) -- | Constructor for computations in the reader monad transformer. readerT :: forall tag r m a. (r -> m a) -> ReaderT tag r m a -- | Runs a ReaderT with the given environment and returns the final -- value. runReaderT :: forall tag r m a. ReaderT tag r m a -> r -> m a type Readers r = ReadersT r Identity runReaders :: forall p a. Readers p a -> p -> a type ReadersT r = TaggedTrans (READERS (Tags r)) (ReaderT r) runReadersT :: forall p m a. ReadersT p m a -> p -> m a type MonadReader' r = MonadReader r r local' :: forall r m a. MonadReader' r m => (r -> r) -> m a -> m a ask' :: forall r m. MonadReader' r m => m r reader' :: forall r m a. MonadReader' r m => (r -> a) -> m a asks' :: forall r m a. MonadReader' r m => (r -> a) -> m a type Reader' r = Reader r r runReader' :: Reader' r a -> r -> a type ReaderT' r = ReaderT r r readerT' :: (r -> m a) -> ReaderT' r m a runReaderT' :: ReaderT' r m a -> r -> m a data TAGGED e t -- | Encode type-level information for ReaderT. data READER instance forall k (t :: (* -> *) -> * -> *) (m :: * -> *) (tag :: k) r. (Control.Monad.Trans.Lift.Local.LiftLocal t, GHC.Base.Monad (t m), Ether.Reader.MonadReader tag r m) => Ether.Reader.MonadReader tag r (t m) instance forall a k (trans :: (GHC.Types.Type -> GHC.Types.Type) -> * -> *) (m :: GHC.Types.Type -> GHC.Types.Type) (tag :: k) r (effs :: [a]) (eff :: a). (GHC.Base.Monad (trans m), Ether.Reader.MonadReader tag r (Ether.TaggedTrans.TaggedTrans effs trans m)) => Ether.Reader.MonadReader tag r (Ether.TaggedTrans.TaggedTrans (eff : effs) trans m) instance Ether.Internal.Handle Ether.Reader.READER r (Control.Monad.Trans.Reader.ReaderT r) instance forall k r (trans :: Ether.Internal.K_Trans) (m :: * -> *) (tag :: k). (Ether.Internal.Handle Ether.Reader.READER r trans, GHC.Base.Monad m, GHC.Base.Monad (trans m)) => Ether.Reader.MonadReader tag r (Ether.TaggedTrans.TaggedTrans (Ether.Internal.TAGGED Ether.Reader.READER tag) trans m) instance forall k (tag :: k) payload r (trans :: Ether.Internal.K_Trans) (m :: * -> *) (effs :: [*]). (Ether.Internal.HasLens.HasLens tag payload r, Ether.Internal.Handle Ether.Reader.READER payload trans, GHC.Base.Monad m, GHC.Base.Monad (trans m)) => Ether.Reader.MonadReader tag r (Ether.TaggedTrans.TaggedTrans (Ether.Internal.TAGGED Ether.Reader.READER tag : effs) trans m) module Ether.State class Monad m => MonadState tag s m | m tag -> s where get = state @tag (\ s -> (s, s)) put s = state @tag (\ _ -> ((), s)) state f = do { s <- get @tag; let ~(a, s') = f s; put @tag s'; return a } -- | Return the state from the internals of the monad. get :: MonadState tag s m => m s -- | Replace the state inside the monad. put :: MonadState tag s m => s -> m () -- | Embed a simple state action into the monad. state :: MonadState tag s m => (s -> (a, s)) -> m a -- | Return the state from the internals of the monad. get :: MonadState tag s m => m s -- | Replace the state inside the monad. put :: MonadState tag s m => s -> m () -- | Embed a simple state action into the monad. state :: MonadState tag s m => (s -> (a, s)) -> m a -- | Modifies the state inside a state monad. modify :: forall tag s m. MonadState tag s m => (s -> s) -> m () -- | Gets specific component of the state, using a projection function -- supplied. gets :: forall tag s m a. MonadState tag s m => (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 :: forall tag s a. 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 :: forall tag s a. State tag s a -> s -> a -- | Runs a State with the given initial state and returns the final -- state, discarding the final value. execState :: forall tag s a. 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 (TAGGED STATE tag) (StateT s) -- | Constructor for computations in the state monad transformer. stateT :: forall tag s m a. (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 :: forall tag s m a. 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 :: forall tag s m a. Monad m => 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 :: forall tag s m a. Monad m => StateT tag s m a -> s -> m s -- | 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 LazyState tag r = LazyStateT tag r Identity -- | Runs a State with the given initial state and returns both the -- final value and the final state. runLazyState :: forall tag s a. LazyState tag s a -> s -> (a, s) -- | Runs a State with the given initial state and returns the final -- value, discarding the final state. evalLazyState :: forall tag s a. LazyState tag s a -> s -> a -- | Runs a State with the given initial state and returns the final -- state, discarding the final value. execLazyState :: forall tag s a. LazyState 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 LazyStateT tag s = TaggedTrans (TAGGED STATE tag) (StateT s) -- | Constructor for computations in the state monad transformer. lazyStateT :: forall tag s m a. (s -> m (a, s)) -> LazyStateT tag s m a -- | Runs a StateT with the given initial state and returns both the -- final value and the final state. runLazyStateT :: forall tag s m a. LazyStateT 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. evalLazyStateT :: forall tag s m a. Monad m => LazyStateT tag s m a -> s -> m a -- | Runs a StateT with the given initial state and returns the -- final state, discarding the final value. execLazyStateT :: forall tag s m a. Monad m => LazyStateT tag s m a -> s -> m s type States s = StatesT s Identity runStates :: forall p a. States p a -> p -> (a, p) type StatesT s = TaggedTrans (STATES (Tags s)) (StateT s) runStatesT :: forall p m a. StatesT p m a -> p -> m (a, p) type MonadState' s = MonadState s s get' :: forall s m. MonadState' s m => m s put' :: forall s m. MonadState' s m => s -> m () state' :: forall s m a. MonadState' s m => (s -> (a, s)) -> m a modify' :: forall s m. MonadState' s m => (s -> s) -> m () gets' :: forall s m a. MonadState' s m => (s -> a) -> m a type State' s = State s s runState' :: State' s a -> s -> (a, s) evalState' :: State' s a -> s -> a execState' :: State' s a -> s -> s type StateT' s = StateT s s stateT' :: (s -> m (a, s)) -> StateT' s m a runStateT' :: StateT' s m a -> s -> m (a, s) evalStateT' :: Monad m => StateT' s m a -> s -> m a execStateT' :: Monad m => StateT' s m a -> s -> m s type LazyState' s = LazyState s s runLazyState' :: LazyState' s a -> s -> (a, s) evalLazyState' :: LazyState' s a -> s -> a execLazyState' :: LazyState' s a -> s -> s type LazyStateT' s = LazyStateT s s lazyStateT' :: (s -> m (a, s)) -> LazyStateT' s m a runLazyStateT' :: LazyStateT' s m a -> s -> m (a, s) evalLazyStateT' :: Monad m => LazyStateT' s m a -> s -> m a execLazyStateT' :: Monad m => LazyStateT' s m a -> s -> m s type ZoomT t (z :: Type) = TaggedTrans (ZOOM t z) IdentityT -- | Zoom into a part of a state using a lens. zoom :: forall tag sOuter sInner m a. Lens' sOuter sInner -> (forall z. Reifies z (ReifiedLens' sOuter sInner) => ZoomT tag z m a) -> m a data TAGGED e t -- | Encode type-level information for StateT. data STATE -- | Encode type-level information for zoom. data ZOOM t z instance forall k (t :: (* -> *) -> * -> *) (m :: * -> *) (tag :: k) s. (Control.Monad.Trans.Class.MonadTrans t, GHC.Base.Monad (t m), Ether.State.MonadState tag s m) => Ether.State.MonadState tag s (t m) instance forall a k (trans :: (GHC.Types.Type -> GHC.Types.Type) -> * -> *) (m :: GHC.Types.Type -> GHC.Types.Type) (tag :: k) s (effs :: [a]) (eff :: a). (GHC.Base.Monad (trans m), Ether.State.MonadState tag s (Ether.TaggedTrans.TaggedTrans effs trans m)) => Ether.State.MonadState tag s (Ether.TaggedTrans.TaggedTrans (eff : effs) trans m) instance Ether.Internal.Handle Ether.State.STATE s (Control.Monad.Trans.State.Strict.StateT s) instance Ether.Internal.Handle Ether.State.STATE s (Control.Monad.Trans.State.Lazy.StateT s) instance forall k s (trans :: Ether.Internal.K_Trans) (m :: * -> *) (tag :: k). (Ether.Internal.Handle Ether.State.STATE s trans, GHC.Base.Monad m, GHC.Base.Monad (trans m)) => Ether.State.MonadState tag s (Ether.TaggedTrans.TaggedTrans (Ether.Internal.TAGGED Ether.State.STATE tag) trans m) instance forall k (tag :: k) payload s (trans :: Ether.Internal.K_Trans) (m :: * -> *) (effs :: [*]). (Ether.Internal.HasLens.HasLens tag payload s, Ether.Internal.Handle Ether.State.STATE payload trans, GHC.Base.Monad m, GHC.Base.Monad (trans m)) => Ether.State.MonadState tag s (Ether.TaggedTrans.TaggedTrans (Ether.Internal.TAGGED Ether.State.STATE tag : effs) trans m) instance forall k k1 (tag :: k1) sOuter (m :: * -> *) (z :: k) sInner (trans :: (* -> *) -> * -> *). (Ether.State.MonadState tag sOuter m, Data.Reflection.Reifies z (Ether.Internal.ReifiedLens' sOuter sInner), trans ~ Control.Monad.Trans.Identity.IdentityT) => Ether.State.MonadState tag sInner (Ether.TaggedTrans.TaggedTrans (Ether.State.ZOOM tag z) trans m) module Ether.Writer class (Monoid w, Monad m) => MonadWriter tag w m | m tag -> w where writer ~(a, w) = a <$ tell @tag w tell w = writer @tag ((), w) -- | Embed a simple writer action. writer :: MonadWriter tag w m => (a, w) -> m a -- | Append a value to the accumulator within the monad. tell :: MonadWriter tag w m => w -> m () -- | Execute an action and add its accumulator to the value of the -- computation. listen :: MonadWriter tag w m => 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 => m (a, w -> w) -> m a -- | Embed a simple writer action. writer :: MonadWriter tag w m => (a, w) -> m a -- | Append a value to the accumulator within the monad. tell :: MonadWriter tag w m => w -> m () -- | Execute an action and add its accumulator to the value of the -- computation. listen :: MonadWriter tag w m => 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 => 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 :: forall tag w m a b. MonadWriter tag w m => (w -> b) -> m a -> m (a, b) -- | Execute an action and apply a function to its accumulator. censor :: forall tag w m a. MonadWriter tag w m => (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 :: forall tag w a. Monoid w => Writer tag w a -> (a, w) -- | Runs a Writer and returns the final accumulator, discarding the -- normal value. execWriter :: forall tag w a. Monoid w => 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 (TAGGED WRITER tag) (WriterT w) -- | Constructor for computations in the writer monad transformer. writerT :: forall tag w m a. (Functor m, Monoid w) => m (a, w) -> WriterT tag w m a -- | Runs a WriterT and returns both the normal value and the final -- accumulator. runWriterT :: forall tag w m a. Monoid w => WriterT tag w m a -> m (a, w) -- | Runs a WriterT and returns the final accumulator, discarding -- the normal value. execWriterT :: forall tag w m a. (Monad m, Monoid w) => WriterT tag w m a -> m w -- | 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 LazyWriter tag w = LazyWriterT tag w Identity -- | Runs a Writer and returns both the normal value and the final -- accumulator. runLazyWriter :: forall tag w a. LazyWriter tag w a -> (a, w) -- | Runs a Writer and returns the final accumulator, discarding the -- normal value. execLazyWriter :: forall tag w a. LazyWriter 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 LazyWriterT tag w = TaggedTrans (TAGGED WRITER tag) (WriterT w) -- | Constructor for computations in the writer monad transformer. lazyWriterT :: forall tag w m a. m (a, w) -> LazyWriterT tag w m a -- | Runs a WriterT and returns both the normal value and the final -- accumulator. runLazyWriterT :: forall tag w m a. LazyWriterT tag w m a -> m (a, w) -- | Runs a WriterT and returns the final accumulator, discarding -- the normal value. execLazyWriterT :: forall tag w m a. Monad m => LazyWriterT tag w m a -> m w type MonadWriter' w = MonadWriter w w writer' :: forall w m a. MonadWriter' w m => (a, w) -> m a tell' :: forall w m. MonadWriter' w m => w -> m () listen' :: forall w m a. MonadWriter' w m => m a -> m (a, w) pass' :: forall w m a. MonadWriter' w m => m (a, w -> w) -> m a listens' :: forall w m a b. MonadWriter' w m => (w -> b) -> m a -> m (a, b) censor' :: forall w m a. MonadWriter' w m => (w -> w) -> m a -> m a type Writer' w = Writer w w runWriter' :: Monoid w => Writer' w a -> (a, w) execWriter' :: Monoid w => Writer' w a -> w type WriterT' w = WriterT w w writerT' :: (Functor m, Monoid w) => m (a, w) -> WriterT' w m a runWriterT' :: Monoid w => WriterT' w m a -> m (a, w) execWriterT' :: (Monad m, Monoid w) => WriterT' w m a -> m w type LazyWriter' w = LazyWriter w w runLazyWriter' :: LazyWriter' w a -> (a, w) execLazyWriter' :: LazyWriter' w a -> w type LazyWriterT' w = LazyWriterT w w lazyWriterT' :: m (a, w) -> LazyWriterT' w m a runLazyWriterT' :: LazyWriterT' w m a -> m (a, w) execLazyWriterT' :: Monad m => LazyWriterT' w m a -> m w data TAGGED e t -- | Encode type-level information for WriterT. data WRITER instance forall k (t :: (* -> *) -> * -> *) (m :: * -> *) (tag :: k) w. (Control.Monad.Trans.Lift.Listen.LiftListen t, Control.Monad.Trans.Lift.Pass.LiftPass t, GHC.Base.Monad (t m), Ether.Writer.MonadWriter tag w m, GHC.Base.Monoid w) => Ether.Writer.MonadWriter tag w (t m) instance GHC.Base.Monoid w => Ether.Internal.Handle Ether.Writer.WRITER w (Control.Monad.Trans.Writer.CPS.Internal.WriterT w) instance GHC.Base.Monoid w => Ether.Internal.Handle Ether.Writer.WRITER w (Control.Monad.Trans.Writer.Lazy.WriterT w) instance forall k w (trans :: Ether.Internal.K_Trans) (m :: * -> *) (tag :: k). (Ether.Internal.Handle Ether.Writer.WRITER w trans, GHC.Base.Monad m, GHC.Base.Monad (trans m)) => Ether.Writer.MonadWriter tag w (Ether.TaggedTrans.TaggedTrans (Ether.Internal.TAGGED Ether.Writer.WRITER tag) trans m) module Ether.Except 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 => e -> m a -- | A TaggedTrans function to handle previous exceptions and return to -- normal execution. catch :: MonadExcept tag e m => m a -> (e -> m a) -> m a -- | Is used within a monadic computation to begin exception processing. throw :: MonadExcept tag e m => e -> m a -- | A TaggedTrans function to handle previous exceptions and return to -- normal execution. catch :: MonadExcept tag e m => 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 :: forall tag e a. 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 (TAGGED EXCEPT tag) (ExceptT e) -- | Constructor for computations in the exception monad transformer. exceptT :: forall tag e m a. m (Either e a) -> ExceptT tag e m a -- | Runs an ExceptT and returns either an exception or a normal -- value. runExceptT :: forall tag e m a. ExceptT tag e m a -> m (Either e a) type MonadExcept' e = MonadExcept e e throw' :: forall e m a. MonadExcept' e m => e -> m a catch' :: forall e m a. MonadExcept' e m => m a -> (e -> m a) -> m a type Except' e = Except e e runExcept' :: Except' e a -> Either e a type ExceptT' e = ExceptT e e exceptT' :: m (Either e a) -> ExceptT' e m a runExceptT' :: ExceptT' e m a -> m (Either e a) data TAGGED e t -- | Encode type-level information for ExceptT. data EXCEPT instance forall k (t :: (* -> *) -> * -> *) (m :: * -> *) (tag :: k) e. (Control.Monad.Trans.Lift.Catch.LiftCatch t, GHC.Base.Monad (t m), Ether.Except.MonadExcept tag e m) => Ether.Except.MonadExcept tag e (t m) instance Ether.Internal.Handle Ether.Except.EXCEPT e (Control.Monad.Trans.Except.ExceptT e) instance forall k e (trans :: Ether.Internal.K_Trans) (m :: * -> *) (tag :: k). (Ether.Internal.Handle Ether.Except.EXCEPT e trans, GHC.Base.Monad m, GHC.Base.Monad (trans m)) => Ether.Except.MonadExcept tag e (Ether.TaggedTrans.TaggedTrans (Ether.Internal.TAGGED Ether.Except.EXCEPT tag) trans m) -- | Type-level machinery to manipulate constraints on the monad -- transformer stack. -- -- Out of the box it provides the following dispatch strategies: -- -- -- --
--   import Ether
--   import Control.Monad.State as Mtl
--   
--   data Foo
--   data Bar
--   
--   f :: Mtl.MonadState Int m => m String
--   f = fmap show Mtl.get
--   
--   g :: Ether.MonadState Foo Int m => m String
--   g = tagAttach @Foo f
--   
--   h :: Ether.MonadState Bar Int m => m String
--   h = tagReplace @Foo @Bar g
--   
module Ether.TagDispatch type TagAttachT t = TaggedTrans (TAG_ATTACH t) IdentityT -- | Attach a tag to untagged transformers. tagAttach :: forall tag m a. TagAttachT tag m a -> m a type TagReplaceT tOld tNew = TaggedTrans (TAG_REPLACE tOld tNew) IdentityT -- | Replace a tag with another tag. tagReplace :: forall tOld tNew m a. TagReplaceT tOld tNew m a -> m a -- | Encode type-level information for tagAttach. data TAG_ATTACH t -- | Encode type-level information for tagReplace. data TAG_REPLACE tOld tNew instance forall k (tag :: k) r (m :: * -> *) (trans :: (* -> *) -> * -> *). (Ether.Reader.MonadReader tag r m, trans ~ Control.Monad.Trans.Identity.IdentityT) => Control.Monad.Reader.Class.MonadReader r (Ether.TaggedTrans.TaggedTrans (Ether.TagDispatch.TAG_ATTACH tag) trans m) instance forall k (tag :: k) s (m :: * -> *) (trans :: (* -> *) -> * -> *). (Ether.State.MonadState tag s m, trans ~ Control.Monad.Trans.Identity.IdentityT) => Control.Monad.State.Class.MonadState s (Ether.TaggedTrans.TaggedTrans (Ether.TagDispatch.TAG_ATTACH tag) trans m) instance forall k (tag :: k) e (m :: * -> *) (trans :: (* -> *) -> * -> *). (Ether.Except.MonadExcept tag e m, trans ~ Control.Monad.Trans.Identity.IdentityT) => Control.Monad.Error.Class.MonadError e (Ether.TaggedTrans.TaggedTrans (Ether.TagDispatch.TAG_ATTACH tag) trans m) instance forall k (tag :: k) w (m :: * -> *) (trans :: (* -> *) -> * -> *). (Ether.Writer.MonadWriter tag w m, trans ~ Control.Monad.Trans.Identity.IdentityT) => Control.Monad.Writer.Class.MonadWriter w (Ether.TaggedTrans.TaggedTrans (Ether.TagDispatch.TAG_ATTACH tag) trans m) instance forall k k1 (tNew :: k1) r (m :: * -> *) (trans :: (* -> *) -> * -> *) (tOld :: k). (Ether.Reader.MonadReader tNew r m, trans ~ Control.Monad.Trans.Identity.IdentityT) => Ether.Reader.MonadReader tOld r (Ether.TaggedTrans.TaggedTrans (Ether.TagDispatch.TAG_REPLACE tOld tNew) trans m) instance forall k k1 (tNew :: k1) s (m :: * -> *) (trans :: (* -> *) -> * -> *) (tOld :: k). (Ether.State.MonadState tNew s m, trans ~ Control.Monad.Trans.Identity.IdentityT) => Ether.State.MonadState tOld s (Ether.TaggedTrans.TaggedTrans (Ether.TagDispatch.TAG_REPLACE tOld tNew) trans m) instance forall k k1 (tNew :: k1) e (m :: * -> *) (trans :: (* -> *) -> * -> *) (tOld :: k). (Ether.Except.MonadExcept tNew e m, trans ~ Control.Monad.Trans.Identity.IdentityT) => Ether.Except.MonadExcept tOld e (Ether.TaggedTrans.TaggedTrans (Ether.TagDispatch.TAG_REPLACE tOld tNew) trans m) instance forall k k1 (tNew :: k1) w (m :: * -> *) (trans :: (* -> *) -> * -> *) (tOld :: k). (Ether.Writer.MonadWriter tNew w m, trans ~ Control.Monad.Trans.Identity.IdentityT) => Ether.Writer.MonadWriter tOld w (Ether.TaggedTrans.TaggedTrans (Ether.TagDispatch.TAG_REPLACE tOld tNew) trans m) module Ether