| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Bricks.UnquotedString
Contents
- newtype Str'Unquoted = Str'Unquoted'Unsafe {}
- str'tryUnquoted :: Text -> Maybe Str'Unquoted
- str'unquoted'orThrow :: Text -> Str'Unquoted
- str'canRenderUnquoted :: Text -> Bool
- char'canRenderUnquoted :: Char -> Bool
Type
newtype Str'Unquoted Source #
A string that can be rendered unquoted. Unquoted strings are restricted to
a conservative set of characters; see str'canRenderUnquoted for the full
rules.
The constructor is tagged "unsafe" because it lets you construct and invalid
value. Prefer str'tryUnquoted which does validate the text.
Constructors
| Str'Unquoted'Unsafe | |
Fields | |
Instances
Constructor
str'tryUnquoted :: Text -> Maybe Str'Unquoted Source #
str'unquoted'orThrow :: Text -> Str'Unquoted Source #
Throws an exception if the string cannot render unquoted.
Predicates
str'canRenderUnquoted :: Text -> Bool Source #
Whether a string having this name can be rendered without quoting it. We allow a string to render unquoted if all these conditions are met:
- The string is nonempty
- All characters satify
char'canRenderUnquoted - The string is not a keyword
>>>str'canRenderUnquoted "-ab_c"True
>>>str'canRenderUnquoted ""False
>>>str'canRenderUnquoted "a\"b"False
>>>str'canRenderUnquoted "let"False
char'canRenderUnquoted :: Char -> Bool Source #
Letters, -, and _.