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

CalamityCommands.Check

Description

Command invokation preconditions

Synopsis

Documentation

data Check m c Source #

A check for a command.

Every check for a command must return Nothing for the command to be run.

Constructors

MkCheck 

Fields

  • name :: Text

    The name of the check.

  • callback :: c -> m (Maybe Text)

    The callback for the check, returns Nothing if it passes, otherwise returns the reason for it not passing.

Instances

Instances details
(k ~ A_Lens, a ~ (c1 -> m1 (Maybe Text)), b ~ (c2 -> m2 (Maybe Text))) => LabelOptic "callback" k (Check m1 c1) (Check m2 c2) a b Source # 
Instance details

Defined in CalamityCommands.Check

Methods

labelOptic :: Optic k NoIx (Check m1 c1) (Check m2 c2) a b #

(k ~ A_Lens, a ~ Text, b ~ Text) => LabelOptic "name" k (Check m c) (Check m c) a b Source # 
Instance details

Defined in CalamityCommands.Check

Methods

labelOptic :: Optic k NoIx (Check m c) (Check m c) a b #

buildCheck :: (Monad m, Member (Final m) r) => Text -> (c -> Sem r (Maybe Text)) -> Sem r (Check m c) Source #

Given the name of a check and a callback in the Sem monad, build a check by transforming the Polysemy action into an m action.

buildCheckPure :: Monad m => Text -> (c -> Maybe Text) -> Check m c Source #

Given the name of a check and a pure callback function, build a check.

runCheck :: (Monad m, Member (Embed m) r) => c -> Check m c -> Sem r (Either CommandError ()) Source #

Given an invokation context c, run a check and transform the result into an Either CommandError ().