ascii-th-1.1.0.0: Template Haskell support for ASCII
Safe HaskellNone
LanguageHaskell2010

ASCII.QuasiQuoters

Description

Use of these quasi-quoters in a pattern context requires the ViewPatterns language extension.

Synopsis

Documentation

char :: QuasiQuoter Source #

An expression pattern corresponding to an ASCII character

In an expression context

The result will have a FromChar constraint.

The quasi-quoted string must consist of a single character that is within the ASCII character set.

[char|e|] == SmallLetterE

[char|e|] == (101 :: Word8)

Since this is polymorphic, a type signature is recommended.

In a pattern context

The pattern matches a value of a type satisfying the ToChar constraint.

let
    x = case Tilde of
          [char|@|] -> 1
          [char|~|] -> 2
          _ -> 3
in
    x == 2

string :: QuasiQuoter Source #

An expression or pattern corresponding to an ASCII string

In an expression context

The result will have a FromString constraint.

The quasi-quoted string must consist only of characters are within the ASCII character set.

[string|Hello!|] ==
    [CapitalLetterH,SmallLetterE,SmallLetterL,SmallLetterL,SmallLetterO,ExclamationMark]

[string|Hello!|] == ("Hello!" :: String)

[string|Hello!|] == ("Hello!" :: Text)

toLazyByteString [string|Hello!|] == "Hello!"

Since this is polymorphic, a type signature is recommended.

In a pattern context

The pattern matches a value of a type satisfying the ToString constraint.

let
    x = case [CapitalLetterH, SmallLetterI] of
          [string|Bye|] -> 1
          [string|Hi|] -> 2
          _ -> 3
in
    x == 2