marvin-0.1.5: A modular chat bot

Copyright(c) Justus Adam 2016
LicenseBSD3
Maintainerdev@justus.science
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Marvin.Adapter

Description

 

Synopsis

Documentation

type EventHandler a = Event a -> IO () Source #

class IsAdapter a where Source #

Basic functionality required of any adapter

Associated Types

type User a Source #

Concrete, adapter specific representation of a user. Could be an id string or a full object for instance

type Channel a Source #

Concrete, adapter specific representation of a channel. Could be an id string or a full object for instance

Methods

adapterId :: AdapterId a Source #

Used for scoping config and logging

messageChannel :: Channel a -> Text -> AdapterM a () Source #

Post a message to a channel given the internal channel identifier

initAdapter :: RunnerM a Source #

Initialize the adapter state

runWithAdapter :: RunWithAdapter a Source #

Run the bot

getUsername :: User a -> AdapterM a Text Source #

Resolve a username given the internal user identifier

getChannelName :: Channel a -> AdapterM a Text Source #

Resolve the human readable name for a channel given the internal channel identifier

resolveChannel :: Text -> AdapterM a (Maybe (Channel a)) Source #

Resolve to the internal channel structure given a human readable name

resolveUser :: Text -> AdapterM a (Maybe (User a)) Source #

Resolve to the internal user structure given a human readable name

data AdapterId a Source #

A type, basically a String, which identifies an adapter to the config and the logging facilities.

For conversion please use mkAdapterId and unwrapAdapterId. They will perform necessary checks.

Instances

mkAdapterId :: Text -> Either String (AdapterId a) Source #

Attempt to create an adapter id from Text

data AdapterM a r Source #

Monad in which adapter actions run in

Instances

MonadBaseControl IO (AdapterM a) Source # 

Associated Types

type StM (AdapterM a :: * -> *) a :: * #

Methods

liftBaseWith :: (RunInBase (AdapterM a) IO -> IO a) -> AdapterM a a #

restoreM :: StM (AdapterM a) a -> AdapterM a a #

MonadBase IO (AdapterM a) Source # 

Methods

liftBase :: IO α -> AdapterM a α #

Monad (AdapterM a) Source # 

Methods

(>>=) :: AdapterM a a -> (a -> AdapterM a b) -> AdapterM a b #

(>>) :: AdapterM a a -> AdapterM a b -> AdapterM a b #

return :: a -> AdapterM a a #

fail :: String -> AdapterM a a #

Functor (AdapterM a) Source # 

Methods

fmap :: (a -> b) -> AdapterM a a -> AdapterM a b #

(<$) :: a -> AdapterM a b -> AdapterM a a #

Applicative (AdapterM a) Source # 

Methods

pure :: a -> AdapterM a a #

(<*>) :: AdapterM a (a -> b) -> AdapterM a a -> AdapterM a b #

(*>) :: AdapterM a a -> AdapterM a b -> AdapterM a b #

(<*) :: AdapterM a a -> AdapterM a b -> AdapterM a a #

MonadIO (AdapterM a) Source # 

Methods

liftIO :: IO a -> AdapterM a a #

MonadLogger (AdapterM a) Source # 

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> AdapterM a () #

MonadLoggerIO (AdapterM a) Source # 

Methods

askLoggerIO :: AdapterM a (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

AccessAdapter (AdapterM a) Source # 

Associated Types

type AdapterT (AdapterM a :: * -> *) :: * Source #

type AdapterT (AdapterM a) Source # 
type AdapterT (AdapterM a) = a
type StM (AdapterM a) r Source # 
type StM (AdapterM a) r = r

data Event a Source #

Representation for the types of events which can occur