    {-# LANGUAGE CPP #-}
    {-# LANGUAGE FlexibleInstances #-}
    {-# LANGUAGE GeneralizedNewtypeDeriving #-}
    {-# LANGUAGE MultiParamTypeClasses #-}
    {-# LANGUAGE TypeFamilies #-}
    {-# LANGUAGE UndecidableInstances #-}
    module Lambdabot.Module
        ( Module(..)
        , newModule

        , ModuleID
        , newModuleID

        , ModuleInfo(..)
        , ModuleT
        , runModuleT
        ) where

    import qualified Lambdabot.Command as Cmd
    import Lambdabot.Config
    import Lambdabot.Logging
    import {-# SOURCE #-} Lambdabot.Monad
    import Lambdabot.Util.Serial

    import Control.Applicative
    import Control.Concurrent (MVar)
    import Control.Monad
    import Control.Monad.Fail (MonadFail)
    import qualified Control.Monad.Fail
    import Control.Monad.Base
    import Control.Monad.Reader (MonadReader(..), ReaderT(..), asks)
    import Control.Monad.Trans (MonadTrans(..), MonadIO(..))
    import Control.Monad.Trans.Control
    import Data.Unique.Tag
    import Control.Monad.Catch (MonadThrow, MonadCatch, MonadMask)
    #if !defined(MIN_VERSION_haskeline) || !MIN_VERSION_haskeline(0,8,0)
    import System.Console.Haskeline.MonadException (MonadException)
    #endif

    ------------------------------------------------------------------------

    -- | The Module type class.
    data Module st = Module {
            -- | If the module wants its state to be saved, this function should
            --   return a Serial.
            --
            --   The default implementation returns Nothing.
            forall st. Module st -> Maybe (Serial st)
    moduleSerialize :: !(Maybe (Serial st)),

            -- | If the module maintains state, this method specifies the default state
            --   (for example in case the state can't be read from a state).
            --
            --   The default implementation returns an error and assumes the state is
            --   never accessed.
            forall st. Module st -> LB st
    moduleDefState  :: !(LB st),

            -- | Is the module sticky? Sticky modules (as well as static ones) can't be
            --   unloaded. By default, modules are not sticky.
            forall st. Module st -> Bool
    moduleSticky    :: !Bool,

            -- | The commands the module listens to.
            forall st. Module st -> ModuleT st LB [Command (ModuleT st LB)]
    moduleCmds      :: !(ModuleT st LB [Cmd.Command (ModuleT st LB)]),

            -- | Initialize the module. The default implementation does nothing.
            forall st. Module st -> ModuleT st LB ()
    moduleInit      :: !(ModuleT st LB ()),

            -- | Finalize the module. The default implementation does nothing.
            forall st. Module st -> ModuleT st LB ()
    moduleExit      :: !(ModuleT st LB ()),

            -- | Process contextual input. A plugin that implements 'contextual'
            -- is able to respond to text not part of a normal command.
            forall st. Module st -> String -> Cmd (ModuleT st LB) ()
    contextual
                :: !(String                           --  the text
                 -> Cmd.Cmd (ModuleT st LB) ())       -- ^ the action
        }

    ------------------------------------------------------------------------

    newModule :: Module st
    newModule :: forall st. Module st
    newModule = Module
        { contextual :: String -> Cmd (ModuleT st LB) ()
    contextual         = \String
    _ -> () -> Cmd (ModuleT st LB) ()
    forall a. a -> Cmd (ModuleT st LB) a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
        , moduleCmds :: ModuleT st LB [Command (ModuleT st LB)]
    moduleCmds         = [Command (ModuleT st LB)]
    -> ModuleT st LB [Command (ModuleT st LB)]
    forall a. a -> ModuleT st LB a
    forall (m :: * -> *) a. Monad m => a -> m a
    return []
        , moduleExit :: ModuleT st LB ()
    moduleExit         = () -> ModuleT st LB ()
    forall a. a -> ModuleT st LB a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
        , moduleInit :: ModuleT st LB ()
    moduleInit         = () -> ModuleT st LB ()
    forall a. a -> ModuleT st LB a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
        , moduleSticky :: Bool
    moduleSticky       = Bool
    False
        , moduleSerialize :: Maybe (Serial st)
    moduleSerialize    = Maybe (Serial st)
    forall a. Maybe a
    Nothing
        , moduleDefState :: LB st
    moduleDefState     = st -> LB st
    forall a. a -> LB a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (st -> LB st) -> st -> LB st
    forall a b. (a -> b) -> a -> b
    $ String -> st
    forall a. HasCallStack => String -> a
    error String
    "state not initialized"
        }

    newtype ModuleID st = ModuleID (Tag RealWorld st)
        deriving ((forall a b. ModuleID a -> ModuleID b -> Maybe (a :~: b))
    -> GEq ModuleID
    forall a b. ModuleID a -> ModuleID b -> Maybe (a :~: b)
    forall k (f :: k -> *).
    (forall (a :: k) (b :: k). f a -> f b -> Maybe (a :~: b)) -> GEq f
    $cgeq :: forall a b. ModuleID a -> ModuleID b -> Maybe (a :~: b)
    geq :: forall a b. ModuleID a -> ModuleID b -> Maybe (a :~: b)
    GEq, GEq ModuleID
    GEq ModuleID =>
    (forall a b. ModuleID a -> ModuleID b -> GOrdering a b)
    -> GCompare ModuleID
    forall a b. ModuleID a -> ModuleID b -> GOrdering a b
    forall k (f :: k -> *).
    GEq f =>
    (forall (a :: k) (b :: k). f a -> f b -> GOrdering a b)
    -> GCompare f
    $cgcompare :: forall a b. ModuleID a -> ModuleID b -> GOrdering a b
    gcompare :: forall a b. ModuleID a -> ModuleID b -> GOrdering a b
    GCompare)

    newModuleID :: IO (ModuleID st)
    newModuleID :: forall st. IO (ModuleID st)
    newModuleID = Tag RealWorld st -> ModuleID st
    forall st. Tag RealWorld st -> ModuleID st
    ModuleID (Tag RealWorld st -> ModuleID st)
    -> IO (Tag RealWorld st) -> IO (ModuleID st)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> IO (Tag RealWorld st)
    IO (Tag (PrimState IO) st)
    forall (m :: * -> *) a. PrimMonad m => m (Tag (PrimState m) a)
    newTag

    -- |Info about a running module.
    data ModuleInfo st = ModuleInfo
        { forall st. ModuleInfo st -> String
    moduleName   :: !String
        , forall st. ModuleInfo st -> ModuleID st
    moduleID     :: !(ModuleID st)
        , forall st. ModuleInfo st -> Module st
    theModule    :: !(Module st)
        , forall st. ModuleInfo st -> MVar st
    moduleState  :: !(MVar st)
        }

    -- | This transformer encodes the additional information a module might
    --   need to access its name or its state.
    newtype ModuleT st m a = ModuleT { forall st (m :: * -> *) a.
    ModuleT st m a -> ReaderT (ModuleInfo st) m a
    unModuleT :: ReaderT (ModuleInfo st) m a }
        deriving (Functor (ModuleT st m)
    Functor (ModuleT st m) =>
    (forall a. a -> ModuleT st m a)
    -> (forall a b.
        ModuleT st m (a -> b) -> ModuleT st m a -> ModuleT st m b)
    -> (forall a b c.
        (a -> b -> c)
        -> ModuleT st m a -> ModuleT st m b -> ModuleT st m c)
    -> (forall a b. ModuleT st m a -> ModuleT st m b -> ModuleT st m b)
    -> (forall a b. ModuleT st m a -> ModuleT st m b -> ModuleT st m a)
    -> Applicative (ModuleT st m)
    forall a. a -> ModuleT st m a
    forall a b. ModuleT st m a -> ModuleT st m b -> ModuleT st m a
    forall a b. ModuleT st m a -> ModuleT st m b -> ModuleT st m b
    forall a b.
    ModuleT st m (a -> b) -> ModuleT st m a -> ModuleT st m b
    forall a b c.
    (a -> b -> c) -> ModuleT st m a -> ModuleT st m b -> ModuleT st m c
    forall st (m :: * -> *). Applicative m => Functor (ModuleT st m)
    forall st (m :: * -> *) a. Applicative m => a -> ModuleT st m a
    forall st (m :: * -> *) a b.
    Applicative m =>
    ModuleT st m a -> ModuleT st m b -> ModuleT st m a
    forall st (m :: * -> *) a b.
    Applicative m =>
    ModuleT st m a -> ModuleT st m b -> ModuleT st m b
    forall st (m :: * -> *) a b.
    Applicative m =>
    ModuleT st m (a -> b) -> ModuleT st m a -> ModuleT st m b
    forall st (m :: * -> *) a b c.
    Applicative m =>
    (a -> b -> c) -> ModuleT st m a -> ModuleT st m b -> ModuleT st m c
    forall (f :: * -> *).
    Functor f =>
    (forall a. a -> f a)
    -> (forall a b. f (a -> b) -> f a -> f b)
    -> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
    -> (forall a b. f a -> f b -> f b)
    -> (forall a b. f a -> f b -> f a)
    -> Applicative f
    $cpure :: forall st (m :: * -> *) a. Applicative m => a -> ModuleT st m a
    pure :: forall a. a -> ModuleT st m a
    $c<*> :: forall st (m :: * -> *) a b.
    Applicative m =>
    ModuleT st m (a -> b) -> ModuleT st m a -> ModuleT st m b
    <*> :: forall a b.
    ModuleT st m (a -> b) -> ModuleT st m a -> ModuleT st m b
    $cliftA2 :: forall st (m :: * -> *) a b c.
    Applicative m =>
    (a -> b -> c) -> ModuleT st m a -> ModuleT st m b -> ModuleT st m c
    liftA2 :: forall a b c.
    (a -> b -> c) -> ModuleT st m a -> ModuleT st m b -> ModuleT st m c
    $c*> :: forall st (m :: * -> *) a b.
    Applicative m =>
    ModuleT st m a -> ModuleT st m b -> ModuleT st m b
    *> :: forall a b. ModuleT st m a -> ModuleT st m b -> ModuleT st m b
    $c<* :: forall st (m :: * -> *) a b.
    Applicative m =>
    ModuleT st m a -> ModuleT st m b -> ModuleT st m a
    <* :: forall a b. ModuleT st m a -> ModuleT st m b -> ModuleT st m a
    Applicative, (forall a b. (a -> b) -> ModuleT st m a -> ModuleT st m b)
    -> (forall a b. a -> ModuleT st m b -> ModuleT st m a)
    -> Functor (ModuleT st m)
    forall a b. a -> ModuleT st m b -> ModuleT st m a
    forall a b. (a -> b) -> ModuleT st m a -> ModuleT st m b
    forall st (m :: * -> *) a b.
    Functor m =>
    a -> ModuleT st m b -> ModuleT st m a
    forall st (m :: * -> *) a b.
    Functor m =>
    (a -> b) -> ModuleT st m a -> ModuleT st m b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    $cfmap :: forall st (m :: * -> *) a b.
    Functor m =>
    (a -> b) -> ModuleT st m a -> ModuleT st m b
    fmap :: forall a b. (a -> b) -> ModuleT st m a -> ModuleT st m b
    $c<$ :: forall st (m :: * -> *) a b.
    Functor m =>
    a -> ModuleT st m b -> ModuleT st m a
    <$ :: forall a b. a -> ModuleT st m b -> ModuleT st m a
    Functor, Applicative (ModuleT st m)
    Applicative (ModuleT st m) =>
    (forall a b.
     ModuleT st m a -> (a -> ModuleT st m b) -> ModuleT st m b)
    -> (forall a b. ModuleT st m a -> ModuleT st m b -> ModuleT st m b)
    -> (forall a. a -> ModuleT st m a)
    -> Monad (ModuleT st m)
    forall a. a -> ModuleT st m a
    forall a b. ModuleT st m a -> ModuleT st m b -> ModuleT st m b
    forall a b.
    ModuleT st m a -> (a -> ModuleT st m b) -> ModuleT st m b
    forall st (m :: * -> *). Monad m => Applicative (ModuleT st m)
    forall st (m :: * -> *) a. Monad m => a -> ModuleT st m a
    forall st (m :: * -> *) a b.
    Monad m =>
    ModuleT st m a -> ModuleT st m b -> ModuleT st m b
    forall st (m :: * -> *) a b.
    Monad m =>
    ModuleT st m a -> (a -> ModuleT st m b) -> ModuleT st m b
    forall (m :: * -> *).
    Applicative m =>
    (forall a b. m a -> (a -> m b) -> m b)
    -> (forall a b. m a -> m b -> m b)
    -> (forall a. a -> m a)
    -> Monad m
    $c>>= :: forall st (m :: * -> *) a b.
    Monad m =>
    ModuleT st m a -> (a -> ModuleT st m b) -> ModuleT st m b
    >>= :: forall a b.
    ModuleT st m a -> (a -> ModuleT st m b) -> ModuleT st m b
    $c>> :: forall st (m :: * -> *) a b.
    Monad m =>
    ModuleT st m a -> ModuleT st m b -> ModuleT st m b
    >> :: forall a b. ModuleT st m a -> ModuleT st m b -> ModuleT st m b
    $creturn :: forall st (m :: * -> *) a. Monad m => a -> ModuleT st m a
    return :: forall a. a -> ModuleT st m a
    Monad, MonadReader (ModuleInfo st),
            (forall (m :: * -> *). Monad m => Monad (ModuleT st m)) =>
    (forall (m :: * -> *) a. Monad m => m a -> ModuleT st m a)
    -> MonadTrans (ModuleT st)
    forall st (m :: * -> *). Monad m => Monad (ModuleT st m)
    forall st (m :: * -> *) a. Monad m => m a -> ModuleT st m a
    forall (m :: * -> *). Monad m => Monad (ModuleT st m)
    forall (m :: * -> *) a. Monad m => m a -> ModuleT st m a
    forall (t :: (* -> *) -> * -> *).
    (forall (m :: * -> *). Monad m => Monad (t m)) =>
    (forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
    $clift :: forall st (m :: * -> *) a. Monad m => m a -> ModuleT st m a
    lift :: forall (m :: * -> *) a. Monad m => m a -> ModuleT st m a
    MonadTrans, Monad (ModuleT st m)
    Monad (ModuleT st m) =>
    (forall a. IO a -> ModuleT st m a) -> MonadIO (ModuleT st m)
    forall a. IO a -> ModuleT st m a
    forall st (m :: * -> *). MonadIO m => Monad (ModuleT st m)
    forall st (m :: * -> *) a. MonadIO m => IO a -> ModuleT st m a
    forall (m :: * -> *).
    Monad m =>
    (forall a. IO a -> m a) -> MonadIO m
    $cliftIO :: forall st (m :: * -> *) a. MonadIO m => IO a -> ModuleT st m a
    liftIO :: forall a. IO a -> ModuleT st m a
    MonadIO, Monad (ModuleT st m)
    Monad (ModuleT st m) =>
    (forall a. Config a -> ModuleT st m a)
    -> MonadConfig (ModuleT st m)
    forall a. Config a -> ModuleT st m a
    forall st (m :: * -> *). MonadConfig m => Monad (ModuleT st m)
    forall st (m :: * -> *) a.
    MonadConfig m =>
    Config a -> ModuleT st m a
    forall (m :: * -> *).
    Monad m =>
    (forall a. Config a -> m a) -> MonadConfig m
    $cgetConfig :: forall st (m :: * -> *) a.
    MonadConfig m =>
    Config a -> ModuleT st m a
    getConfig :: forall a. Config a -> ModuleT st m a
    MonadConfig, Monad (ModuleT st m)
    Monad (ModuleT st m) =>
    (forall a. String -> ModuleT st m a) -> MonadFail (ModuleT st m)
    forall a. String -> ModuleT st m a
    forall st (m :: * -> *). MonadFail m => Monad (ModuleT st m)
    forall st (m :: * -> *) a. MonadFail m => String -> ModuleT st m a
    forall (m :: * -> *).
    Monad m =>
    (forall a. String -> m a) -> MonadFail m
    $cfail :: forall st (m :: * -> *) a. MonadFail m => String -> ModuleT st m a
    fail :: forall a. String -> ModuleT st m a
    MonadFail,
    #if !defined(MIN_VERSION_haskeline) || !MIN_VERSION_haskeline(0,8,0)
            MonadException,
    #endif
            Monad (ModuleT st m)
    Monad (ModuleT st m) =>
    (forall e a. (HasCallStack, Exception e) => e -> ModuleT st m a)
    -> MonadThrow (ModuleT st m)
    forall e a. (HasCallStack, Exception e) => e -> ModuleT st m a
    forall st (m :: * -> *). MonadThrow m => Monad (ModuleT st m)
    forall st (m :: * -> *) e a.
    (MonadThrow m, HasCallStack, Exception e) =>
    e -> ModuleT st m a
    forall (m :: * -> *).
    Monad m =>
    (forall e a. (HasCallStack, Exception e) => e -> m a)
    -> MonadThrow m
    $cthrowM :: forall st (m :: * -> *) e a.
    (MonadThrow m, HasCallStack, Exception e) =>
    e -> ModuleT st m a
    throwM :: forall e a. (HasCallStack, Exception e) => e -> ModuleT st m a
    MonadThrow, MonadThrow (ModuleT st m)
    MonadThrow (ModuleT st m) =>
    (forall e a.
     (HasCallStack, Exception e) =>
     ModuleT st m a -> (e -> ModuleT st m a) -> ModuleT st m a)
    -> MonadCatch (ModuleT st m)
    forall e a.
    (HasCallStack, Exception e) =>
    ModuleT st m a -> (e -> ModuleT st m a) -> ModuleT st m a
    forall st (m :: * -> *). MonadCatch m => MonadThrow (ModuleT st m)
    forall st (m :: * -> *) e a.
    (MonadCatch m, HasCallStack, Exception e) =>
    ModuleT st m a -> (e -> ModuleT st m a) -> ModuleT st m a
    forall (m :: * -> *).
    MonadThrow m =>
    (forall e a.
     (HasCallStack, Exception e) =>
     m a -> (e -> m a) -> m a)
    -> MonadCatch m
    $ccatch :: forall st (m :: * -> *) e a.
    (MonadCatch m, HasCallStack, Exception e) =>
    ModuleT st m a -> (e -> ModuleT st m a) -> ModuleT st m a
    catch :: forall e a.
    (HasCallStack, Exception e) =>
    ModuleT st m a -> (e -> ModuleT st m a) -> ModuleT st m a
    MonadCatch, MonadCatch (ModuleT st m)
    MonadCatch (ModuleT st m) =>
    (forall b.
     HasCallStack =>
     ((forall a. ModuleT st m a -> ModuleT st m a) -> ModuleT st m b)
     -> ModuleT st m b)
    -> (forall b.
        HasCallStack =>
        ((forall a. ModuleT st m a -> ModuleT st m a) -> ModuleT st m b)
        -> ModuleT st m b)
    -> (forall a b c.
        HasCallStack =>
        ModuleT st m a
        -> (a -> ExitCase b -> ModuleT st m c)
        -> (a -> ModuleT st m b)
        -> ModuleT st m (b, c))
    -> MonadMask (ModuleT st m)
    forall b.
    HasCallStack =>
    ((forall a. ModuleT st m a -> ModuleT st m a) -> ModuleT st m b)
    -> ModuleT st m b
    forall a b c.
    HasCallStack =>
    ModuleT st m a
    -> (a -> ExitCase b -> ModuleT st m c)
    -> (a -> ModuleT st m b)
    -> ModuleT st m (b, c)
    forall st (m :: * -> *). MonadMask m => MonadCatch (ModuleT st m)
    forall st (m :: * -> *) b.
    (MonadMask m, HasCallStack) =>
    ((forall a. ModuleT st m a -> ModuleT st m a) -> ModuleT st m b)
    -> ModuleT st m b
    forall st (m :: * -> *) a b c.
    (MonadMask m, HasCallStack) =>
    ModuleT st m a
    -> (a -> ExitCase b -> ModuleT st m c)
    -> (a -> ModuleT st m b)
    -> ModuleT st m (b, c)
    forall (m :: * -> *).
    MonadCatch m =>
    (forall b. HasCallStack => ((forall a. m a -> m a) -> m b) -> m b)
    -> (forall b.
        HasCallStack =>
        ((forall a. m a -> m a) -> m b) -> m b)
    -> (forall a b c.
        HasCallStack =>
        m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c))
    -> MonadMask m
    $cmask :: forall st (m :: * -> *) b.
    (MonadMask m, HasCallStack) =>
    ((forall a. ModuleT st m a -> ModuleT st m a) -> ModuleT st m b)
    -> ModuleT st m b
    mask :: forall b.
    HasCallStack =>
    ((forall a. ModuleT st m a -> ModuleT st m a) -> ModuleT st m b)
    -> ModuleT st m b
    $cuninterruptibleMask :: forall st (m :: * -> *) b.
    (MonadMask m, HasCallStack) =>
    ((forall a. ModuleT st m a -> ModuleT st m a) -> ModuleT st m b)
    -> ModuleT st m b
    uninterruptibleMask :: forall b.
    HasCallStack =>
    ((forall a. ModuleT st m a -> ModuleT st m a) -> ModuleT st m b)
    -> ModuleT st m b
    $cgeneralBracket :: forall st (m :: * -> *) a b c.
    (MonadMask m, HasCallStack) =>
    ModuleT st m a
    -> (a -> ExitCase b -> ModuleT st m c)
    -> (a -> ModuleT st m b)
    -> ModuleT st m (b, c)
    generalBracket :: forall a b c.
    HasCallStack =>
    ModuleT st m a
    -> (a -> ExitCase b -> ModuleT st m c)
    -> (a -> ModuleT st m b)
    -> ModuleT st m (b, c)
    MonadMask)

    runModuleT :: ModuleT st m a -> ModuleInfo st -> m a
    runModuleT :: forall st (m :: * -> *) a. ModuleT st m a -> ModuleInfo st -> m a
    runModuleT = ReaderT (ModuleInfo st) m a -> ModuleInfo st -> m a
    forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
    runReaderT (ReaderT (ModuleInfo st) m a -> ModuleInfo st -> m a)
    -> (ModuleT st m a -> ReaderT (ModuleInfo st) m a)
    -> ModuleT st m a
    -> ModuleInfo st
    -> m a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ModuleT st m a -> ReaderT (ModuleInfo st) m a
    forall st (m :: * -> *) a.
    ModuleT st m a -> ReaderT (ModuleInfo st) m a
    unModuleT

    instance MonadLogging m => MonadLogging (ModuleT st m) where
        getCurrentLogger :: ModuleT st m [String]
    getCurrentLogger = do
            parent <- m [String] -> ModuleT st m [String]
    forall (m :: * -> *) a. Monad m => m a -> ModuleT st m a
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift m [String]
    forall (m :: * -> *). MonadLogging m => m [String]
    getCurrentLogger
            self   <- asks moduleName
            return (parent ++ ["Plugin", self])
        logM :: String -> Priority -> String -> ModuleT st m ()
    logM String
    a Priority
    b String
    c = m () -> ModuleT st m ()
    forall (m :: * -> *) a. Monad m => m a -> ModuleT st m a
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (String -> Priority -> String -> m ()
    forall (m :: * -> *).
    MonadLogging m =>
    String -> Priority -> String -> m ()
    logM String
    a Priority
    b String
    c)

    instance MonadBase b m => MonadBase b (ModuleT st m) where
        liftBase :: forall α. b α -> ModuleT st m α
    liftBase = m α -> ModuleT st m α
    forall (m :: * -> *) a. Monad m => m a -> ModuleT st m a
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (m α -> ModuleT st m α) -> (b α -> m α) -> b α -> ModuleT st m α
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . b α -> m α
    forall α. b α -> m α
    forall (b :: * -> *) (m :: * -> *) α. MonadBase b m => b α -> m α
    liftBase

    instance MonadTransControl (ModuleT st) where
        type StT (ModuleT st) a = a
        liftWith :: forall (m :: * -> *) a.
    Monad m =>
    (Run (ModuleT st) -> m a) -> ModuleT st m a
    liftWith Run (ModuleT st) -> m a
    f = do
            r <- ReaderT (ModuleInfo st) m (ModuleInfo st)
    -> ModuleT st m (ModuleInfo st)
    forall st (m :: * -> *) a.
    ReaderT (ModuleInfo st) m a -> ModuleT st m a
    ModuleT ReaderT (ModuleInfo st) m (ModuleInfo st)
    forall r (m :: * -> *). MonadReader r m => m r
    ask
            lift $ f $ \ModuleT st n b
    t -> ModuleT st n b -> ModuleInfo st -> n b
    forall st (m :: * -> *) a. ModuleT st m a -> ModuleInfo st -> m a
    runModuleT ModuleT st n b
    t ModuleInfo st
    r
        restoreT :: forall (m :: * -> *) a.
    Monad m =>
    m (StT (ModuleT st) a) -> ModuleT st m a
    restoreT = m a -> ModuleT st m a
    m (StT (ModuleT st) a) -> ModuleT st m a
    forall (m :: * -> *) a. Monad m => m a -> ModuleT st m a
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift
        {-# INLINE liftWith #-}
        {-# INLINE restoreT #-}

    instance MonadBaseControl b m => MonadBaseControl b (ModuleT st m) where
        type StM (ModuleT st m) a = ComposeSt (ModuleT st) m a
        liftBaseWith :: forall a. (RunInBase (ModuleT st m) b -> b a) -> ModuleT st m a
    liftBaseWith = (RunInBaseDefault (ModuleT st) m b -> b a) -> ModuleT st m a
    (RunInBase (ModuleT st m) b -> b a) -> ModuleT st m a
    forall (t :: (* -> *) -> * -> *) (b :: * -> *) (m :: * -> *) a.
    (MonadTransControl t, MonadBaseControl b m) =>
    (RunInBaseDefault t m b -> b a) -> t m a
    defaultLiftBaseWith
        restoreM :: forall a. StM (ModuleT st m) a -> ModuleT st m a
    restoreM     = ComposeSt (ModuleT st) m a -> ModuleT st m a
    StM (ModuleT st m) a -> ModuleT st m a
    forall (t :: (* -> *) -> * -> *) (b :: * -> *) (m :: * -> *) a.
    (MonadTransControl t, MonadBaseControl b m) =>
    ComposeSt t m a -> t m a
    defaultRestoreM
        {-# INLINE liftBaseWith #-}
        {-# INLINE restoreM #-}