bricks-syntax-0.0.0.4: ...

Bricks.UnquotedString

Synopsis

Type

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

• unquotedString'try
• unquotedString'orThrow

Deconstruction

• unquotedString'text

• text'canBeUnquoted
• char'canBeUnquoted

Instances

 Source # MethodsshowList :: [UnquotedString] -> ShowS #

Construction

Properties

• A text value may be used to construct an UnquotedString iff it satisfies text'canBeUnquoted.

text'canBeUnquoted x = isJust (unquotedString'try x)

Throws an exception if the string cannot render unquoted.

Predicates

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:

• The string is nonempty
• All characters satify char'canBeUnquoted
• The string is not a keyword

Properties

• A text value may be used to construct an UnquotedString iff it satisfies text'canBeUnquoted.

text'canBeUnquoted x = isJust (unquotedString'try x)

Examples

>>> text'canBeUnquoted "-ab_c"
True

>>> text'canBeUnquoted ""
False

>>> text'canBeUnquoted "a\"b"
False

>>> text'canBeUnquoted "let"
False


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.