Copyright | (C) CSIRO 2017-2018 |
---|---|
License | BSD3 |
Maintainer | George Wilson <george.wilson@data61.csiro.au> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- newtype Unescaped a = Unescaped {
- getRawUnescaped :: a
- type Escaper s t = Char -> Unescaped s -> t
- type Escaper' a = Char -> Unescaped a -> a
- escapeString :: Escaper' String
- escapeText :: Escaper' Text
- escapeUtf8 :: Escaper' ByteString
- escapeUtf8Lazy :: Escaper' ByteString
- escapeChar :: Escaper Char String
Documentation
Wrapper for text that is known to be in an unescaped form
Unescaped | |
|
Instances
type Escaper s t = Char -> Unescaped s -> t Source #
A function that, given a char, escapes all occurrences of that char.
This version allows the escaping to be type-changing. For example, escaping a single char can result in a string with two characters.
type Escaper' a = Char -> Unescaped a -> a Source #
A function that, given a char, escapes all occurrences of that char.
escapeString :: Escaper' String Source #
Replaces all occurrences of the given character with two occurrences of that
character, non-recursively, in the given String
.
>>>
escapeString ''' "hello 'string'"
"hello ''string''"
escapeText :: Escaper' Text Source #
Replaces all occurrences of the given character with two occurrences of that
character in the given Text
{- LANGUAGE OverloadedStrings -} >>> escapeText ''' "hellotext
" "hello 'text'
"
escapeUtf8 :: Escaper' ByteString Source #
Replaces all occurrences of the given character with two occurrences of that character in the given ByteString, which is assumed to be UTF-8 compatible.
{- LANGUAGE OverloadedStrings -} >>> escapeUtf8 ''' "hellobytestring
" "hello 'bytestring'
"
escapeUtf8Lazy :: Escaper' ByteString Source #
Replaces all occurrences of the given character with two occurrences of that character in the given lazy ByteString, which is assumed to be UTF-8 compatible.
{- LANGUAGE OverloadedStrings -} >>> escapeUtf8Lazy ''' "hello 'lazy bytestring'" "hello ''lazy bytestring''"