Safe Haskell | None |
---|---|
Language | Haskell98 |
Synopsis
- lambdabotVersion :: Version
- data Config t
- data DSum (tag :: k -> Type) (f :: k -> Type) :: forall k. (k -> Type) -> (k -> Type) -> Type where
- (==>) :: Applicative f => tag a -> a -> DSum tag f
- lambdabotMain :: Modules -> [DSum Config Identity] -> IO ExitCode
- type Modules = [(String, Some Module)]
- modules :: [String] -> Q Exp
- module Lambdabot.Plugin.Core
- data Priority
Documentation
data DSum (tag :: k -> Type) (f :: k -> Type) :: forall k. (k -> Type) -> (k -> Type) -> Type where #
A basic dependent sum type; the first component is a tag that specifies the type of the second; for example, think of a GADT such as:
data Tag a where AString :: Tag String AnInt :: Tag Int
Then, we have the following valid expressions of type Applicative f => DSum Tag f
:
AString ==> "hello!" AnInt ==> 42
And we can write functions that consume DSum Tag f
values by matching,
such as:
toString :: DSum Tag Identity -> String toString (AString :=> Identity str) = str toString (AnInt :=> Identity int) = show int
By analogy to the (key => value) construction for dictionary entries in
many dynamic languages, we use (key :=> value) as the constructor for
dependent sums. The :=> and ==> operators have very low precedence and
bind to the right, so if the Tag
GADT is extended with an additional
constructor Rec :: Tag (DSum Tag Identity)
, then Rec ==> AnInt ==> 3 + 4
is parsed as would be expected (Rec ==> (AnInt ==> (3 + 4))
) and has type
DSum Identity Tag
. Its precedence is just above that of $
, so
foo bar $ AString ==> "eep"
is equivalent to foo bar (AString ==> "eep")
.
(:=>) :: forall k (tag :: k -> Type) (f :: k -> Type) (a :: k). !(tag a) -> f a -> DSum tag f infixr 1 |
Instances
EqTag tag f => Eq (DSum tag f) | |
OrdTag tag f => Ord (DSum tag f) | |
ReadTag tag f => Read (DSum tag f) | |
ShowTag tag f => Show (DSum tag f) | |
(==>) :: Applicative f => tag a -> a -> DSum tag f infixr 1 #
lambdabotMain :: Modules -> [DSum Config Identity] -> IO ExitCode Source #
The Lambdabot entry point. Initialise plugins, connect, and run the bot in the LB monad
Also, handle any fatal exceptions (such as non-recoverable signals), (i.e. print a message and exit). Non-fatal exceptions should be dealt with in the mainLoop or further down.
module Lambdabot.Plugin.Core
Priorities are used to define how important a log message is. Users can filter log messages based on priorities.
These have their roots on the traditional syslog system. The standard definitions are given below, but you are free to interpret them however you like. They are listed here in ascending importance order.
DEBUG | Debug messages |
INFO | Information |
NOTICE | Normal runtime conditions |
WARNING | General Warnings |
ERROR | General Errors |
CRITICAL | Severe situations |
ALERT | Take immediate action |
EMERGENCY | System is unusable |
Instances
Bounded Priority | |
Enum Priority | |
Eq Priority | |
Ord Priority | |
Read Priority | |
Show Priority | |