calamity-commands-0.4.1.0: A library for declaring, parsing, and invoking text-input based commands
Safe HaskellSafe-Inferred
LanguageHaskell2010

CalamityCommands.Context

Description

Command context typeclass

Synopsis

Documentation

class CommandContext m c a | c -> m, c -> a where Source #

Methods

ctxPrefix :: c -> Text Source #

The prefix that was used to invoke the command

ctxCommand :: c -> Command m c a Source #

The command that was invoked

ctxUnparsedParams :: c -> Text Source #

The message remaining after consuming the prefix

Instances

Instances details
CommandContext m (BasicContext m a) a Source # 
Instance details

Defined in CalamityCommands.Context

data ConstructContext msg ctx m' a' m a where Source #

An effect for constructing the context for a command

Constructors

ConstructContext

Construct a context for a command invokation, returning Just context on success, or Nothing if a context could not be constructed

Fields

constructContext :: forall msg ctx m' a' r. Member (ConstructContext msg ctx m' a') r => (Text, Command m' ctx a', Text) -> msg -> Sem r (Maybe ctx) Source #

Construct a context for a command invokation, returning Just context on success, or Nothing if a context could not be constructed

data BasicContext m a Source #

A basic context that only knows the prefix used and the unparsed input

Constructors

BasicContext 

Instances

Instances details
(k ~ A_Lens, a1 ~ Command m1 (BasicContext m1 a2) a2, b ~ Command m2 (BasicContext m2 a3) a3) => LabelOptic "bcCommand" k (BasicContext m1 a2) (BasicContext m2 a3) a1 b Source # 
Instance details

Defined in CalamityCommands.Context

Methods

labelOptic :: Optic k NoIx (BasicContext m1 a2) (BasicContext m2 a3) a1 b #

(k ~ A_Lens, a1 ~ Text, b ~ Text) => LabelOptic "bcPrefix" k (BasicContext m a2) (BasicContext m a2) a1 b Source # 
Instance details

Defined in CalamityCommands.Context

Methods

labelOptic :: Optic k NoIx (BasicContext m a2) (BasicContext m a2) a1 b #

(k ~ A_Lens, a1 ~ Text, b ~ Text) => LabelOptic "bcUnparsedParams" k (BasicContext m a2) (BasicContext m a2) a1 b Source # 
Instance details

Defined in CalamityCommands.Context

Methods

labelOptic :: Optic k NoIx (BasicContext m a2) (BasicContext m a2) a1 b #

CommandContext m (BasicContext m a) a Source # 
Instance details

Defined in CalamityCommands.Context

Show (BasicContext m a) Source # 
Instance details

Defined in CalamityCommands.Context

useBasicContext :: Sem (ConstructContext msg (BasicContext m a') m a' ': r) a -> Sem r a Source #

A default interpretation for ConstructContext that constructs a BasicContext