lambdabot-core-5.1.0.1: Lambdabot core functionality

Safe HaskellNone
LanguageHaskell98

Lambdabot.Main

Synopsis

Documentation

data Config t Source #

Instances

GEq * Config Source # 

Methods

geq :: f a -> f b -> Maybe ((Config := a) b) #

GCompare * Config Source # 

Methods

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

data DSum k tag f :: forall k. (k -> *) -> (k -> *) -> * 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").

Constructors

(:=>) :: DSum k tag f infixr 1 

Instances

EqTag k tag f => Eq (DSum k tag f) 

Methods

(==) :: DSum k tag f -> DSum k tag f -> Bool #

(/=) :: DSum k tag f -> DSum k tag f -> Bool #

OrdTag k tag f => Ord (DSum k tag f) 

Methods

compare :: DSum k tag f -> DSum k tag f -> Ordering #

(<) :: DSum k tag f -> DSum k tag f -> Bool #

(<=) :: DSum k tag f -> DSum k tag f -> Bool #

(>) :: DSum k tag f -> DSum k tag f -> Bool #

(>=) :: DSum k tag f -> DSum k tag f -> Bool #

max :: DSum k tag f -> DSum k tag f -> DSum k tag f #

min :: DSum k tag f -> DSum k tag f -> DSum k tag f #

ReadTag k tag f => Read (DSum k tag f) 

Methods

readsPrec :: Int -> ReadS (DSum k tag f) #

readList :: ReadS [DSum k tag f] #

readPrec :: ReadPrec (DSum k tag f) #

readListPrec :: ReadPrec [DSum k tag f] #

ShowTag k tag f => Show (DSum k tag f) 

Methods

showsPrec :: Int -> DSum k tag f -> ShowS #

show :: DSum k tag f -> String #

showList :: [DSum k tag f] -> ShowS #

(==>) :: 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.