lambdabot-core-5.3.1.2: Lambdabot core functionality

Safe Haskell | None
Language | Haskell98

Lambdabot.Module

Synopsis

- data Module st = Module {
  - moduleSerialize :: !(Maybe (Serial st))
  - moduleDefState :: !(LB st)
  - moduleSticky :: !Bool
  - moduleCmds :: !(ModuleT st LB [Command (ModuleT st LB)])
  - moduleInit :: !(ModuleT st LB ())
  - moduleExit :: !(ModuleT st LB ())
  - contextual :: !(String -> Cmd (ModuleT st LB) ())
  }
- newModule :: Module st
- data ModuleID st
- newModuleID :: IO (ModuleID st)
- data ModuleInfo st = ModuleInfo {
  - moduleName :: !String
  - moduleID :: !(ModuleID st)
  - theModule :: !(Module st)
  - moduleState :: !(MVar st)
  }
- data ModuleT st (m :: Type -> Type) a
- runModuleT :: ModuleT st m a -> ModuleInfo st -> m a

# Documentation

data Module st Source #

The Module type class.

Constructors

Module |

Fields

- moduleSerialize :: !(Maybe (Serial st))

  If the module wants its state to be saved, this function should return a Serial.

  The default implementation returns Nothing.

- moduleDefState :: !(LB 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.

- moduleSticky :: !Bool

  Is the module sticky? Sticky modules (as well as static ones) can't be unloaded. By default, modules are not sticky.

- moduleCmds :: !(ModuleT st LB [Command (ModuleT st LB)])

  The commands the module listens to.

- moduleInit :: !(ModuleT st LB ())

  Initialize the module. The default implementation does nothing.

- moduleExit :: !(ModuleT st LB ())

  Finalize the module. The default implementation does nothing.

- contextual :: !(String -> Cmd (ModuleT st LB) ())

  Process contextual input. A plugin that implements `contextual` is able to respond to text not part of a normal command.

newModule :: Module st Source #

data ModuleID st Source #

#### Instances

Instances details

GCompare ModuleID Source # |
Instance details Defined in Lambdabot.Module Methods gcompare :: ModuleID a -> ModuleID b -> GOrdering a b #
GEq ModuleID Source # |
Instance details Defined in Lambdabot.Module Methods geq :: ModuleID a -> ModuleID b -> Maybe (a :~: b) #

newModuleID :: IO (ModuleID st) Source #

data ModuleInfo st Source #

Info about a running module.

Constructors

ModuleInfo |

Fields

- moduleName :: !String
- moduleID :: !(ModuleID st)
- theModule :: !(Module st)
- moduleState :: !(MVar st)

#### Instances

Instances details

Monad m => MonadReader (ModuleInfo st) (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods ask :: ModuleT st m (ModuleInfo st) Source # local :: (ModuleInfo st -> ModuleInfo st) -> ModuleT st m a -> ModuleT st m a Source # reader :: (ModuleInfo st -> a) -> ModuleT st m a Source #

data ModuleT st (m :: Type -> Type) a Source #

This transformer encodes the additional information a module might need to access its name or its state.

#### Instances

Instances details

MonadBaseControl b m => MonadBaseControl b (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods liftBaseWith :: (RunInBase (ModuleT st m) b -> b a) -> ModuleT st m a Source # restoreM :: StM (ModuleT st m) a -> ModuleT st m a Source #
MonadBase b m => MonadBase b (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods liftBase :: b α -> ModuleT st m α Source #
MonadTransControl (ModuleT st) Source # |
Instance details Defined in Lambdabot.Module Methods liftWith :: Monad m => (Run (ModuleT st) -> m a) -> ModuleT st m a Source # restoreT :: Monad m => m (StT (ModuleT st) a) -> ModuleT st m a Source #
MonadTrans (ModuleT st) Source # |
Instance details Defined in Lambdabot.Module Methods lift :: Monad m => m a -> ModuleT st m a Source #
Monad m => MonadReader (ModuleInfo st) (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods ask :: ModuleT st m (ModuleInfo st) Source # local :: (ModuleInfo st -> ModuleInfo st) -> ModuleT st m a -> ModuleT st m a Source # reader :: (ModuleInfo st -> a) -> ModuleT st m a Source #
MonadIO m => MonadIO (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods liftIO :: IO a -> ModuleT st m a Source #
MonadCatch m => MonadCatch (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods catch :: (HasCallStack, Exception e) => ModuleT st m a -> (e -> ModuleT st m a) -> ModuleT st m a Source #
MonadMask m => MonadMask (ModuleT st m) Source # |

Instance details

Defined in Lambdabot.Module

Methods

mask :: HasCallStack => ((forall a. ModuleT st m a -> ModuleT st m a) -> ModuleT st m b) -> ModuleT st m b Source #

uninterruptibleMask :: HasCallStack => ((forall a. ModuleT st m a -> ModuleT st m a) -> ModuleT st m b) -> ModuleT st m b Source #

generalBracket :: HasCallStack => ModuleT st m a -> (a -> ExitCase b -> ModuleT st m c) -> (a -> ModuleT st m b) -> ModuleT st m (b, c) Source #

MonadThrow m => MonadThrow (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods throwM :: (HasCallStack, Exception e) => e -> ModuleT st m a Source #
Applicative m => Applicative (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods pure :: a -> ModuleT st m a Source # (<*>) :: ModuleT st m (a -> b) -> ModuleT st m a -> ModuleT st m b Source # liftA2 :: (a -> b -> c) -> ModuleT st m a -> ModuleT st m b -> ModuleT st m c Source # (*>) :: ModuleT st m a -> ModuleT st m b -> ModuleT st m b Source # (<*) :: ModuleT st m a -> ModuleT st m b -> ModuleT st m a Source #
Functor m => Functor (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods fmap :: (a -> b) -> ModuleT st m a -> ModuleT st m b Source # (<$) :: a -> ModuleT st m b -> ModuleT st m a Source #
Monad m => Monad (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods (>>=) :: ModuleT st m a -> (a -> ModuleT st m b) -> ModuleT st m b Source # (>>) :: ModuleT st m a -> ModuleT st m b -> ModuleT st m b Source # return :: a -> ModuleT st m a Source #
MonadFail m => MonadFail (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods fail :: String -> ModuleT st m a Source #
MonadConfig m => MonadConfig (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods getConfig :: Config a -> ModuleT st m a Source #
MonadLogging m => MonadLogging (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Module Methods getCurrentLogger :: ModuleT st m [String] Source # logM :: String -> Priority -> String -> ModuleT st m () Source #
MonadLB m => MonadLB (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Monad Methods lb :: LB a -> ModuleT st m a Source #
MonadLB m => MonadLBState (ModuleT st m) Source # |

Instance details

Defined in Lambdabot.State

Associated Types

type LBState (ModuleT st m) |
Instance details Defined in Lambdabot.State type LBState (ModuleT st m) = st

Methods

withMS :: (LBState (ModuleT st m) -> (LBState (ModuleT st m) -> ModuleT st m ()) -> ModuleT st m a) -> ModuleT st m a Source #

type StT (ModuleT st) a Source # |
Instance details Defined in Lambdabot.Module type StT (ModuleT st) a = a
type LBState (ModuleT st m) Source # |
Instance details Defined in Lambdabot.State type LBState (ModuleT st m) = st
type StM (ModuleT st m) a Source # |
Instance details Defined in Lambdabot.Module type StM (ModuleT st m) a = ComposeSt (ModuleT st) m a

runModuleT :: ModuleT st m a -> ModuleInfo st -> m a Source #