symbols-0.3.0.0: Symbol manipulation

Safe HaskellSafe
LanguageHaskell2010

Data.Symbol.Ascii

Synopsis

Documentation

type family Head (sym :: Symbol) :: Symbol where ... Source #

Compute the first character of a type-level symbol

>>> :kind! Head "Example"
Head "Example" :: Symbol
= "E"
>>> :kind! Head ""
Head "" :: Symbol
= ""

Head doesn't fail if the first character is ASCII, rest is irrelevant

>>> :kind! Head "123±456"
Head "123±456" :: Symbol
= "1"

Head fails if the first character is non-ASCII

>>> :kind! Head "±123"
Head "±123" :: Symbol
= (TypeError ...)

Equations

Head "" = "" 
Head sym = Head1 sym (CmpSymbol sym "\128") 

type family ToList (sym :: Symbol) :: [Symbol] where ... Source #

Convert the symbol into a list of characters

>>> :kind! ToList "ABC"
ToList "ABC" :: [Symbol]
= '["A", "B", "C"]

ToList works only for ASCII strings

>>> :kind! ToList "123±456"
ToList "123±456" :: [Symbol]
= "1" : "2" : "3" : (TypeError ...)

Equations

ToList sym = ToList1 sym "" 

type family ToUpper (sym :: Symbol) :: Symbol where ... Source #

Convert the symbol to uppercase

Equations

ToUpper sym = ToUpper1 (ToList sym) 

type family ToLower (sym :: Symbol) :: Symbol where ... Source #

Convert the symbol to lowercase

Equations

ToLower sym = ToLower1 (ToList sym) 

type family ReadNat (sym :: Symbol) :: Nat where ... Source #

Parse a natural number

Equations

ReadNat sym = ReadNat1 sym (ToList sym)