lambdabot-core-5.3.1.2: Lambdabot core functionality

Safe Haskell | None
Language | Haskell98

Lambdabot.Monad

Synopsis

- data IRCRState
- initRoState :: [DSum Config Identity] -> IO IRCRState
- reportInitDone :: LB ()
- waitForInit :: MonadLB m => m ()
- waitForQuit :: MonadLB m => m ()
- type Callback st = IrcMessage -> ModuleT st LB ()
- type OutputFilter st = Nick -> [String] -> ModuleT st LB [String]
- type Server st = IrcMessage -> ModuleT st LB ()
- data IRCRWState = IRCRWState {
  - ircServerMap :: Map String (DSum ModuleID ServerRef)
  - ircPrivilegedUsers :: Set Nick
  - ircIgnoredUsers :: Set Nick
  - ircChannels :: Map ChanName String
  - ircPersists :: Map String Bool
  - ircModulesByName :: Map String (Some ModuleInfo)
  - ircModulesByID :: DMap ModuleID ModuleInfo
  - ircCallbacks :: Map String (DMap ModuleID CallbackRef)
  - ircOutputFilters :: [DSum ModuleID OutputFilterRef]
  - ircCommands :: Map String (DSum ModuleID CommandRef)
  }
- initRwState :: IRCRWState
- data LB a
- runLB :: LB a -> (IRCRState, IORef IRCRWState) -> IO a
- class (MonadIO m, MonadBaseControl IO m, MonadConfig m, MonadLogging m, Applicative m, MonadFail m) => MonadLB (m :: Type -> Type) where
  - lb :: LB a -> m a
- registerModule :: String -> Module st -> st -> LB (ModuleInfo st)
- registerCommands :: [Command (ModuleT st LB)] -> ModuleT st LB ()
- registerCallback :: String -> Callback st -> ModuleT st LB ()
- registerOutputFilter :: OutputFilter st -> ModuleT st LB ()
- unregisterModule :: String -> LB ()
- registerServer :: String -> Server st -> ModuleT st LB ()
- unregisterServer :: String -> ModuleT mod LB ()
- send :: IrcMessage -> LB ()
- received :: IrcMessage -> LB ()
- applyOutputFilters :: Nick -> String -> LB [String]
- inModuleNamed :: String -> LB a -> (forall st. ModuleT st LB a) -> LB a
- inModuleWithID :: ModuleID st -> LB a -> ModuleT st LB a -> LB a
- withCommand :: String -> LB a -> (forall st. Command (ModuleT st LB) -> ModuleT st LB a) -> LB a
- listModules :: LB [String]
- withAllModules :: (forall st. ModuleT st LB a) -> LB ()

# Documentation

data IRCRState Source #

Global read-only state.

initRoState :: [DSum Config Identity] -> IO IRCRState Source #

Default ro state

reportInitDone :: LB () Source #

waitForInit :: MonadLB m => m () Source #

waitForQuit :: MonadLB m => m () Source #

type Callback st = IrcMessage -> ModuleT st LB () Source #

type OutputFilter st = Nick -> [String] -> ModuleT st LB [String] Source #

type Server st = IrcMessage -> ModuleT st LB () Source #

data IRCRWState Source #

Global read/write state.

Constructors

IRCRWState |

Fields

- ircServerMap :: Map String (DSum ModuleID ServerRef)
- ircPrivilegedUsers :: Set Nick
- ircIgnoredUsers :: Set Nick
- ircChannels :: Map ChanName String

  maps channel names to topics

- ircPersists :: Map String Bool

  lists servers to which to reconnect on failure (one-time or always)

- ircModulesByName :: Map String (Some ModuleInfo)
- ircModulesByID :: DMap ModuleID ModuleInfo
- ircCallbacks :: Map String (DMap ModuleID CallbackRef)
- ircOutputFilters :: [DSum ModuleID OutputFilterRef]

  Output filters, invoked from right to left

- ircCommands :: Map String (DSum ModuleID CommandRef)

#### Instances

Instances details

MonadState IRCRWState LB Source # |
Instance details Defined in Lambdabot.Monad Methods get :: LB IRCRWState Source # put :: IRCRWState -> LB () Source # state :: (IRCRWState -> (a, IRCRWState)) -> LB a Source #

initRwState :: IRCRWState Source #

Default rw state

data LB a Source #

The IRC Monad. The reader transformer holds information about the connection to the IRC server.

instances Monad, Functor, MonadIO, MonadState, MonadError

#### Instances

Instances details

MonadIO LB Source # |
Instance details Defined in Lambdabot.Monad Methods liftIO :: IO a -> LB a Source #
MonadCatch LB Source # |
Instance details Defined in Lambdabot.Monad Methods catch :: (HasCallStack, Exception e) => LB a -> (e -> LB a) -> LB a Source #
MonadMask LB Source # |
Instance details Defined in Lambdabot.Monad Methods mask :: HasCallStack => ((forall a. LB a -> LB a) -> LB b) -> LB b Source # uninterruptibleMask :: HasCallStack => ((forall a. LB a -> LB a) -> LB b) -> LB b Source # generalBracket :: HasCallStack => LB a -> (a -> ExitCase b -> LB c) -> (a -> LB b) -> LB (b, c) Source #
MonadThrow LB Source # |
Instance details Defined in Lambdabot.Monad Methods throwM :: (HasCallStack, Exception e) => e -> LB a Source #
Applicative LB Source # |
Instance details Defined in Lambdabot.Monad Methods pure :: a -> LB a Source # (<*>) :: LB (a -> b) -> LB a -> LB b Source # liftA2 :: (a -> b -> c) -> LB a -> LB b -> LB c Source # (*>) :: LB a -> LB b -> LB b Source # (<*) :: LB a -> LB b -> LB a Source #
Functor LB Source # |
Instance details Defined in Lambdabot.Monad Methods fmap :: (a -> b) -> LB a -> LB b Source # (<$) :: a -> LB b -> LB a Source #
Monad LB Source # |
Instance details Defined in Lambdabot.Monad Methods (>>=) :: LB a -> (a -> LB b) -> LB b Source # (>>) :: LB a -> LB b -> LB b Source # return :: a -> LB a Source #
MonadFail LB Source # |
Instance details Defined in Lambdabot.Monad Methods fail :: String -> LB a Source #
MonadConfig LB Source # |
Instance details Defined in Lambdabot.Monad Methods getConfig :: Config a -> LB a Source #
MonadLogging LB Source # |
Instance details Defined in Lambdabot.Monad Methods getCurrentLogger :: LB [String] Source # logM :: String -> Priority -> String -> LB () Source #
MonadLB LB Source # |
Instance details Defined in Lambdabot.Monad Methods lb :: LB a -> LB a Source #
MonadBaseControl IO LB Source # |

Instance details

Defined in Lambdabot.Monad

Associated Types

type StM LB a |
Instance details Defined in Lambdabot.Monad type StM LB a = StM (ReaderT (IRCRState, IORef IRCRWState) IO) a

Methods

liftBaseWith :: (RunInBase LB IO -> IO a) -> LB a Source #

restoreM :: StM LB a -> LB a Source #

MonadState IRCRWState LB Source # |
Instance details Defined in Lambdabot.Monad Methods get :: LB IRCRWState Source # put :: IRCRWState -> LB () Source # state :: (IRCRWState -> (a, IRCRWState)) -> LB a Source #
MonadBase IO LB Source # |
Instance details Defined in Lambdabot.Monad Methods liftBase :: IO α -> LB α Source #
type StM LB a Source # |
Instance details Defined in Lambdabot.Monad type StM LB a = StM (ReaderT (IRCRState, IORef IRCRWState) IO) a

runLB :: LB a -> (IRCRState, IORef IRCRWState) -> IO a Source #

class (MonadIO m, MonadBaseControl IO m, MonadConfig m, MonadLogging m, Applicative m, MonadFail m) => MonadLB (m :: Type -> Type) where Source #

Methods

lb :: LB a -> m a Source #

#### Instances

Instances details

MonadLB LB Source # |
Instance details Defined in Lambdabot.Monad Methods lb :: LB a -> LB a Source #
MonadLB m => MonadLB (Cmd m) Source # |
Instance details Defined in Lambdabot.Monad Methods lb :: LB a -> Cmd m a Source #
MonadLB m => MonadLB (ModuleT st m) Source # |
Instance details Defined in Lambdabot.Monad Methods lb :: LB a -> ModuleT st m a Source #

registerModule :: String -> Module st -> st -> LB (ModuleInfo st) Source #

registerCommands :: [Command (ModuleT st LB)] -> ModuleT st LB () Source #

registerCallback :: String -> Callback st -> ModuleT st LB () Source #

registerOutputFilter :: OutputFilter st -> ModuleT st LB () Source #

unregisterModule :: String -> LB () Source #

registerServer :: String -> Server st -> ModuleT st LB () Source #

unregisterServer :: String -> ModuleT mod LB () Source #

send :: IrcMessage -> LB () Source #

received :: IrcMessage -> LB () Source #

applyOutputFilters :: Nick -> String -> LB [String] Source #

inModuleNamed :: String -> LB a -> (forall st. ModuleT st LB a) -> LB a Source #

Interpret an expression in the context of a module.

inModuleWithID :: ModuleID st -> LB a -> ModuleT st LB a -> LB a Source #

withCommand :: String -> LB a -> (forall st. Command (ModuleT st LB) -> ModuleT st LB a) -> LB a Source #

listModules :: LB [String] Source #

withAllModules :: (forall st. ModuleT st LB a) -> LB () Source #

Interpret a function in the context of all modules