Safe Haskell | None |
---|---|
Language | Haskell98 |
Extensible configuration system for lambdabot
TODO: there's notthing lambdabot-specific about this, it could be a useful standalone library.
Documentation
getConfigDefault :: Config t -> t Source #
mergeConfig :: Config t -> t -> t -> t Source #
class Monad m => MonadConfig m where Source #
Instances
MonadConfig LB Source # | |
MonadConfig m => MonadConfig (Cmd m) Source # | |
MonadConfig m => MonadConfig (ReaderT r m) Source # | |
(MonadConfig m, Monoid w) => MonadConfig (WriterT w m) Source # | |
MonadConfig m => MonadConfig (StateT s m) Source # | |
MonadConfig m => MonadConfig (ModuleT st m) 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, (++)
).