Char

Core

Functions for working with characters. Character literals are enclosed in a pair of single quotes:

'a'
'0'
'Z'
'?'
'Σ'
'🙈'

'\t'
'\''
'\u{1F648}' -- '🙈'

**Note:** You cannot use single quotes around multiple characters. That is how String and Char values are distinguished in syntax.

Values

isDigit

isDigit : Char -> Bool

Detect digits 0123456789.

Examples

isDigit '0' == True
isDigit '9' == True
isDigit 'a' == False
isDigit 'A' == False

isOctDigit

isOctDigit : Char -> Bool

Detect octal digits 01234567.

Examples

isOctDigit '0' == True
isOctDigit '7' == True
isOctDigit '8' == False
isOctDigit 'a' == False

isHexDigit

isHexDigit : Char -> Bool

Detect hexadecimal digits 0123456789abcdefABCDEF.

Examples

isHexDigit 'a' == True
isHexDigit 'F' == True
isHexDigit 'g' == False

isUpper

isUpper : Char -> Bool

Detect upper case ASCII characters.

Examples

isUpper 'A' == True
isUpper 'Z' == True
isUpper '0' == False
isUpper 'a' == False
isUpper 'Σ' == False

isLower

isLower : Char -> Bool

Detect lower case ASCII characters.

Examples

isLower 'a' == True
isLower 'z' == True
isLower '0' == False
isLower 'A' == False
isLower 'π' == False

isAlpha

isAlpha : Char -> Bool

Detect upper case and lower case ASCII characters.

Examples

isAlpha 'a' == True
isAlpha 'E' == True
isAlpha '0' == False
isAlpha 'π' == False

isAlphaNum

isAlphaNum : Char -> Bool

Detect upper case and lower case ASCII characters, or digits.

Examples

isAlphaNum 'a' == True
isAlphaNum '0' == True
isAlphaNum '-' == False
isAlphaNum 'π' == False

toUpper

toUpper : Char -> Char

Convert to upper case.

Examples

toUpper 'a' == 'A'
toUpper 'A' == 'A'

toLower

toLower : Char -> Char

Convert to lower case.

Examples

toLower 'A' == 'a'
toLower 'a' == 'a'

toLocaleUpper

toLocaleUpper : Char -> Char

Convert to upper case, according to any locale-specific case mappings.

toLocaleLower

toLocaleLower : Char -> Char

Convert to lower case, according to any locale-specific case mappings.

toCode

toCode : Char -> Int

Convert to the corresponding Unicode code point.

Examples

toCode 'A' == 65
toCode 'B' == 66
toCode '木' == 0x6728
toCode '😃' == 0x1F603

fromCode

fromCode : Int -> Char

Convert a Unicode code point to a character.

Examples

fromCode 65      == 'A'
fromCode 66      == 'B'
fromCode 0x6728  == '木'
fromCode 0x1F603 == '😃'
fromCode -1      == '�'

The full range of unicode is from 0 to 0x10FFFF. With numbers outside that range, you get the replacement character.