Safe Haskell | None |
---|
Provides utility functions for composing skills
- newtype Condition = Condition {}
- data Consumer = Consumer !Condition !Invokable
- data Skill = Skill {}
- data Recipe = Recipe {}
- class ToConsumer c where
- toConsumer :: c -> Consumer
- class Extensible e where
- (!+) :: ToConsumer c => e -> c -> e
- (>!+) :: (ToConsumer c, Monad m, Extensible e) => m e -> c -> m e
- (!+>) :: (ToConsumer c, Monad m, Extensible e) => e -> m c -> m e
- (>!+>) :: (ToConsumer c, Monad m, Extensible e) => m e -> m c -> m e
- skill :: String -> Skill
- recipe :: RecipeMethod -> String -> Recipe
- validConsumer :: (Append r Nil r, CallMask m r, Tuplify r t) => m -> (t -> Handler) -> Consumer
- validCondition :: (Append r Nil r, CallMask m r, Tuplify r t) => m -> (t -> Prerequisite) -> Condition
- (#->) :: (Append r Nil r, CallMask m r, Tuplify r t) => m -> (t -> Handler) -> Consumer
- (#->>) :: CallMask m Nil => m -> Handler -> Consumer
- focusDirectC :: Consumer
- optionallyFocusDirectC :: Consumer
- callRecipe :: RecipeMethod -> Consumer
- runConsumer :: ToConsumer c => c -> Invokable
- wrapSkills :: [Skill] -> String -> Maybe Invokable
- wrapRecipes :: [Recipe] -> String -> Maybe (RecipeMethod -> Invokable)
Utility types
A wrapper type for skill execution preconditions.
A single consumer. Build it using bareAction
, bareCondition
and monoid concatenation.
Skill | |
|
class ToConsumer c whereSource
Typeclass for everything that may act as a consumer.
toConsumer :: c -> ConsumerSource
Compositors
class Extensible e whereSource
Typeclass for everything that may be extended by consumers using !+
(!+) :: ToConsumer c => e -> c -> eSource
Add a consumer to the skill.
(>!+) :: (ToConsumer c, Monad m, Extensible e) => m e -> c -> m eSource
Add a consumer to the monadic extensible
(!+>) :: (ToConsumer c, Monad m, Extensible e) => e -> m c -> m eSource
Add a monadic consumer to the extensible
(>!+>) :: (ToConsumer c, Monad m, Extensible e) => m e -> m c -> m eSource
Add a monadic consumer to the monadic extensible
Builders
skill :: String -> SkillSource
Build a bogus skill that does nothing but has a name. Use this with !+
to build powerful skills.
recipe :: RecipeMethod -> String -> RecipeSource
Build a bogus recipe that does nothing has a name and a usage method. Use this with !+
to build powerful recipes.
validConsumer :: (Append r Nil r, CallMask m r, Tuplify r t) => m -> (t -> Handler) -> ConsumerSource
Build a consumer using new-style input validation
validCondition :: (Append r Nil r, CallMask m r, Tuplify r t) => m -> (t -> Prerequisite) -> ConditionSource
Build a condition using new-style input validation
(#->) :: (Append r Nil r, CallMask m r, Tuplify r t) => m -> (t -> Handler) -> ConsumerSource
Infix version of validConsumer
(#->>) :: CallMask m Nil => m -> Handler -> ConsumerSource
Infix version of validConsumer, swallowing the empty handler parameter
Sample consumers
focusDirectC :: ConsumerSource
Focus direct object
optionallyFocusDirectC :: ConsumerSource
Optionally ocus direct object (obligatory if none is focused yet)
callRecipe :: RecipeMethod -> ConsumerSource
Dispatch the remaining part of the line as a recipe call
Final wrappers
runConsumer :: ToConsumer c => c -> InvokableSource
Run the given consumer
wrapSkills :: [Skill] -> String -> Maybe InvokableSource
Wrap the skills into a form that is accepted by stereotypes.
wrapRecipes :: [Recipe] -> String -> Maybe (RecipeMethod -> Invokable)Source
Wrap the recipes into a form that is accepted by stereotypes.