bricks-syntax-0.0.0.4: ...

Safe HaskellSafe
LanguageHaskell2010

Bricks.UnquotedString

Contents

Synopsis

Type

data UnquotedString Source #

A string that can be rendered unquoted. Unquoted strings are restricted to a conservative set of characters; see text'canBeUnquoted for the full rules.

This type does not represent a particular part of Bricks syntax, but it is a wrapper for Text that enforces the limitations of strings at various places in the Bricks syntax.

Construction

Deconstruction

See also

Construction

unquotedString'try :: Text -> Maybe UnquotedString Source #

Properties

unquotedString'orThrow :: Text -> UnquotedString Source #

Throws an exception if the string cannot render unquoted.

Deconstruction

Predicates

text'canBeUnquoted :: Text -> Bool Source #

Whether a string having this name can be rendered without quoting it.

Requirements for unquoted strings

We allow a string to render unquoted if all these conditions are met:

Properties

Examples

>>> text'canBeUnquoted "-ab_c"
True
>>> text'canBeUnquoted ""
False
>>> text'canBeUnquoted "a\"b"
False
>>> text'canBeUnquoted "let"
False

char'canBeUnquoted :: Char -> Bool Source #

Whether the character is allowed to be included in an UnquotedString. Such characters are letters, +, -, *, /, and _.

This is used in the implementation of text'canBeUnquoted.