| Copyright | (c) Eric Mertens 2016 |
|---|---|
| License | ISC |
| Maintainer | emertens@gmail.com |
| Safe Haskell | Safe |
| Language | Haskell2010 |
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
- data ExpansionChunk
- parseExpansion :: Text -> Either Text [ExpansionChunk]
- resolveMacroExpansions :: Alternative f => (Text -> f Text) -> (Integer -> f Text) -> [ExpansionChunk] -> f Text
- data Macro = Macro {
- macroSpec :: MacroSpec
- macroCommands :: [[ExpansionChunk]]
- data MacroSpec where
- parseMacroSpecs :: Text -> Either Text MacroSpec
- noMacroArguments :: MacroSpec
Documentation
data ExpansionChunk Source #
Parsed chunk of an expandable command
Constructors
| LiteralChunk Text | regular text |
| VariableChunk Text | inline variable |
| IntegerChunk Integer | inline variable |
| DefaultChunk ExpansionChunk Text | bracketed variable with default |
Instances
| Show ExpansionChunk Source # | |
Defined in Client.Commands.Interpolation Methods showsPrec :: Int -> ExpansionChunk -> ShowS # show :: ExpansionChunk -> String # showList :: [ExpansionChunk] -> ShowS # | |
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.
Constructors
| Macro | |
Fields
| |
noMacroArguments :: MacroSpec Source #
Specification used when unspecified, no arguments.