glirc-2.33.1: Console IRC client

Copyright(c) Eric Mertens 2016
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellSafe
LanguageHaskell2010

Client.Commands.Interpolation

Description

This module is able to parse commands with inline variables and then to evaluate those variables to produce a complete command that varies by the current context.

Variables are built from 1 or more letters.

Optional arguments are suffixed with a ?

Remaining text arguments are suffixed with a *

Synopsis

Documentation

data ExpansionChunk Source #

Parsed chunk of an expandable command

Constructors

LiteralChunk Text

regular text

VariableChunk Text

inline variable $x or ${x y}

IntegerChunk Integer

inline variable $1 or ${1}

DefaultChunk ExpansionChunk Text

bracketed variable with default ${x|lit}

parseExpansion :: Text -> Either Text [ExpansionChunk] Source #

Parse a Text searching for the expansions as specified in ExpansionChunk. $$ is used to escape a single $.

resolveMacroExpansions Source #

Arguments

:: Alternative f 
=> (Text -> f Text)

variable resolution

-> (Integer -> f Text)

argument index resolution

-> [ExpansionChunk]

chunks

-> f Text

concatenated, expanded chunks

Attempt to expand all of the elements in the given list using the two expansion functions. If the expansion of any chunk fails the whole expansion fails.

data Macro Source #

Constructors

Macro 
Instances
Show Macro Source # 
Instance details

Defined in Client.Commands.Interpolation

Methods

showsPrec :: Int -> Macro -> ShowS #

show :: Macro -> String #

showList :: [Macro] -> ShowS #

data MacroSpec where Source #

Constructors

MacroSpec :: (forall r. Args r [String]) -> MacroSpec 
Instances
Show MacroSpec Source # 
Instance details

Defined in Client.Commands.Interpolation

noMacroArguments :: MacroSpec Source #

Specification used when unspecified, no arguments.