curly-expander-0.3.0.0: Curly braces (brackets) expanding
LicenseLGPL-3
Maintainerp-w@stty.cz
Stabilitytesting
PortabilityPOSIX
Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.CurlyExpander

Description

This is the main (and only) module of the curly-expander package.

Synopsis

Documentation

curlyExpand :: Text -> [Text] Source #

Curly braces (brackets) expand function

First argument is a Text, which you want to expand. Second argument is a list of expanded Texts.

There are given few usage examples:

>>> curlyExpand "car{A,B}"
["carA","carB"]
>>> curlyExpand "car{1..5}"
["car1","car2","car3","car4","car5"]
>>> curlyExpand "car{{A,B},{C,D}}"
["carA", "carB", "carC", "carD"]
>>> curlyExpand "{car,bus}{A..C}"
["carA", "carB", "carC", "busA", "busB", "busC"]

Be aware, that these examples will run only with OverloadedStrings language extension and proper Text imports.

data BackslashConfig Source #

This configuration specify, how should be backslashes handled. It is part of ExpandConfig.

Constructors

NoHandle

If no handle is used, then backslashes are not handled in any special way.

Preserve

If preserve is used, backslashes are processed, any backslashed char is processed as nonspecial char and backslashes aren't deleted from result.

Standard

If standard is used, backslashes are processed, any backslashed char is processed as nonspecial char and backslashes are deleted from result.

Instances

Instances details
Eq BackslashConfig Source # 
Instance details

Defined in Text.CurlyExpander

data ExpandConfig Source #

The curly braces expand config. It is used in customCurlyExpand.

Constructors

ExpandConfig 

Fields

  • backslashConfig :: BackslashConfig

    The configuration, which defines, how should be backslashes handled (\)

  • quotePairs :: [(String, String)]

    Quote pairs, which encloses a substrings, tells expander, that the substring shouldn't be expanded. For example ("[", "]") pairs tells to expander, that anything inside [ANYTHING] shouldn't be expanded.

  • persistQuotePairs :: Bool

    If true, quote pairs aren't deleted. Otherwise they are deleted from a result.

  • allowOneElementExpand :: Bool

    If true, curly brackets around one element will be deleted. Otherwise they are persisted.

defaultExpandConfig :: ExpandConfig Source #

The default curly braces expand function config. By default backslashes are not handeled, there are no quote pairs and one element expand is forbidden. See the source code for details.

customCurlyExpand :: ExpandConfig -> Text -> [Text] Source #

Custom curly braces (brackets) expand function. It works in the same way as curlyExpand, bud accept custom configuration ExpandConfig in the first argument.