lambdabot-core-5.3: Lambdabot core functionality

Safe HaskellNone
LanguageHaskell98

Lambdabot.Config

Description

Extensible configuration system for lambdabot

TODO: there's notthing lambdabot-specific about this, it could be a useful standalone library.

Synopsis

Documentation

data Config t Source #

Instances
GCompare Config Source # 
Instance details

Defined in Lambdabot.Config

Methods

gcompare :: Config a -> Config b -> GOrdering a b #

GEq Config Source # 
Instance details

Defined in Lambdabot.Config

Methods

geq :: Config a -> Config b -> Maybe (a :~: b) #

mergeConfig :: Config t -> t -> t -> t Source #

class Monad m => MonadConfig m where Source #

Methods

getConfig :: Config a -> m a Source #

Instances
MonadConfig LB Source # 
Instance details

Defined in Lambdabot.Monad

Methods

getConfig :: Config a -> LB a Source #

MonadConfig m => MonadConfig (Cmd m) Source # 
Instance details

Defined in Lambdabot.Command

Methods

getConfig :: Config a -> Cmd m a Source #

(MonadConfig m, Monoid w) => MonadConfig (WriterT w m) Source # 
Instance details

Defined in Lambdabot.Config

Methods

getConfig :: Config a -> WriterT w m a Source #

MonadConfig m => MonadConfig (StateT s m) Source # 
Instance details

Defined in Lambdabot.Config

Methods

getConfig :: Config a -> StateT s 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 #

MonadConfig m => MonadConfig (ReaderT r m) Source # 
Instance details

Defined in Lambdabot.Config

Methods

getConfig :: Config a -> ReaderT r m a Source #

config :: String -> TypeQ -> ExpQ -> Q [Dec] Source #

Define a new configuration key with the specified name, type and default value

You should probably also provide an explicit export list for any module that defines config keys, because the definition introduces a few extra types that will clutter up the export list otherwise.

configWithMerge :: ExpQ -> String -> TypeQ -> ExpQ -> Q [Dec] Source #

Like config, but also allowing you to specify a "merge rule" that will be used to combine multiple bindings of the same key.

For example, in Lambdabot.Config.Core, onStartupCmds is defined as a list of commands to execute on startup. Its default value is ["offlinerc"], so if a user invokes the default lambdabot executable without arguments, they will get a REPL. Each instance of "-e" on the command-line adds a binding of the form:

onStartupCmds :=> [command]

So if they give one "-e", it replaces the default (note that it is _not_ merged with the default - the default is discarded), and if they give more than one they are merged using the specified operation (in this case, `(++)`).