Version of Unicode standard used by base:
15.1.0.
Modulebase-4.20.2.0Haskell2010
GHC.Unicode
Implementations for the character predicates (isLower, isUpper, etc.) and the conversions (toUpper, toLower). The implementation uses libunicode on Unix systems if that is available.
- 1 type
- 23 values
- Packagebase-4.20.2.0
- Exports24
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceUnicode.hs
Unicode General Categories (column 2 of the UnicodeData table) in the order they are listed in the Unicode standard (the Unicode Character Database, in particular).
Examples
Basic usage:
:t OtherLetterOtherLetter :: GeneralCategory
Eq instance:
UppercaseLetter == UppercaseLetterTrueUppercaseLetter == LowercaseLetterFalse
Ord instance:
NonSpacingMark <= MathSymbolTrue
Enum instance:
enumFromTo ModifierLetter SpacingCombiningMark[ModifierLetter,OtherLetter,NonSpacingMark,SpacingCombiningMark]
Text.Read.Read instance:
read "DashPunctuation" :: GeneralCategoryDashPunctuationread "17" :: GeneralCategory*** Exception: Prelude.read: no parse
Show instance:
show EnclosingMark"EnclosingMark"
Bounded instance:
minBound :: GeneralCategoryUppercaseLettermaxBound :: GeneralCategoryNotAssigned
Ix instance:
import GHC.Internal.Data.Ix ( index )index (OtherLetter,Control) FinalQuote12index (OtherLetter,Control) Format*** Exception: Error in array index
Constructors
UppercaseLetterLu: Letter, Uppercase
LowercaseLetterLl: Letter, Lowercase
TitlecaseLetterLt: Letter, Titlecase
ModifierLetterLm: Letter, Modifier
OtherLetterLo: Letter, Other
NonSpacingMarkMn: Mark, Non-Spacing
SpacingCombiningMarkMc: Mark, Spacing Combining
EnclosingMarkMe: Mark, Enclosing
DecimalNumberNd: Number, Decimal
LetterNumberNl: Number, Letter
OtherNumberNo: Number, Other
ConnectorPunctuationPc: Punctuation, Connector
DashPunctuationPd: Punctuation, Dash
OpenPunctuationPs: Punctuation, Open
ClosePunctuationPe: Punctuation, Close
InitialQuotePi: Punctuation, Initial quote
FinalQuotePf: Punctuation, Final quote
OtherPunctuationPo: Punctuation, Other
MathSymbolSm: Symbol, Math
CurrencySymbolSc: Symbol, Currency
ModifierSymbolSk: Symbol, Modifier
OtherSymbolSo: Symbol, Other
SpaceZs: Separator, Space
LineSeparatorZl: Separator, Line
ParagraphSeparatorZp: Separator, Paragraph
ControlCc: Other, Control
FormatCf: Other, Format
SurrogateCs: Other, Surrogate
PrivateUseCo: Other, Private Use
NotAssignedCn: Other, Not Assigned
Instances9Bounded, Enum, Eq, Ord, Read, Show, …
Bounded GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.UnicodeEnum GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.UnicodeEq GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.UnicodeOrd GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.UnicodeRead GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.ReadShow GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.UnicodeIx GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.UnicodeGeneric GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.Genericstype Rep GeneralCategory = D1 ('MetaDataDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics"GeneralCategory"
"GHC.Internal.Unicode"
"ghc-internal"
'False) ((((C1 ('MetaCons"UppercaseLetter"
'PrefixI 'False) U1 :+: (C1 ('MetaCons"LowercaseLetter"
'PrefixI 'False) U1 :+: C1 ('MetaCons"TitlecaseLetter"
'PrefixI 'False) U1)) :+: ((C1 ('MetaCons"ModifierLetter"
'PrefixI 'False) U1 :+: C1 ('MetaCons"OtherLetter"
'PrefixI 'False) U1) :+: (C1 ('MetaCons"NonSpacingMark"
'PrefixI 'False) U1 :+: C1 ('MetaCons"SpacingCombiningMark"
'PrefixI 'False) U1))) :+: (((C1 ('MetaCons"EnclosingMark"
'PrefixI 'False) U1 :+: C1 ('MetaCons"DecimalNumber"
'PrefixI 'False) U1) :+: (C1 ('MetaCons"LetterNumber"
'PrefixI 'False) U1 :+: C1 ('MetaCons"OtherNumber"
'PrefixI 'False) U1)) :+: ((C1 ('MetaCons"ConnectorPunctuation"
'PrefixI 'False) U1 :+: C1 ('MetaCons"DashPunctuation"
'PrefixI 'False) U1) :+: (C1 ('MetaCons"OpenPunctuation"
'PrefixI 'False) U1 :+: C1 ('MetaCons"ClosePunctuation"
'PrefixI 'False) U1)))) :+: (((C1 ('MetaCons"InitialQuote"
'PrefixI 'False) U1 :+: (C1 ('MetaCons"FinalQuote"
'PrefixI 'False) U1 :+: C1 ('MetaCons"OtherPunctuation"
'PrefixI 'False) U1)) :+: ((C1 ('MetaCons"MathSymbol"
'PrefixI 'False) U1 :+: C1 ('MetaCons"CurrencySymbol"
'PrefixI 'False) U1) :+: (C1 ('MetaCons"ModifierSymbol"
'PrefixI 'False) U1 :+: C1 ('MetaCons"OtherSymbol"
'PrefixI 'False) U1))) :+: (((C1 ('MetaCons"Space"
'PrefixI 'False) U1 :+: C1 ('MetaCons"LineSeparator"
'PrefixI 'False) U1) :+: (C1 ('MetaCons"ParagraphSeparator"
'PrefixI 'False) U1 :+: C1 ('MetaCons"Control"
'PrefixI 'False) U1)) :+: ((C1 ('MetaCons"Format"
'PrefixI 'False) U1 :+: C1 ('MetaCons"Surrogate"
'PrefixI 'False) U1) :+: (C1 ('MetaCons"PrivateUse"
'PrefixI 'False) U1 :+: C1 ('MetaCons"NotAssigned"
'PrefixI 'False) U1)))))
The Unicode general category of the character. This relies on the Enum instance of GeneralCategory, which must remain in the same order as the categories are presented in the Unicode standard.
Examples
Basic usage:
generalCategory 'a'LowercaseLettergeneralCategory 'A'UppercaseLettergeneralCategory '0'DecimalNumbergeneralCategory '%'OtherPunctuationgeneralCategory '♥'OtherSymbolgeneralCategory '\31'ControlgeneralCategory ' 'Space
Selects the first 128 characters of the Unicode character set, corresponding to the ASCII character set.
Selects the first 256 characters of the Unicode character set, corresponding to the ISO 8859-1 (Latin-1) character set.
Selects control characters, which are the non-printing characters of the Latin-1 subset of Unicode.
Selects printable Unicode characters (letters, numbers, marks, punctuation, symbols and spaces).
This function returns False if its argument has one of the following GeneralCategorys, or True otherwise:
Returns True for any Unicode space character, and the control
characters \t, \n, \r, \f, \v.
Selects upper-case or title-case alphabetic Unicode characters (letters). Title case is used by a small number of letter ligatures like the single-character form of Lj.
Note: this predicate does not work for letter-like characters such as:
'Ⓐ' (U+24B6 circled Latin capital letter A) and
'Ⅳ' (U+2163 Roman numeral four). This is due to selecting only
characters with the GeneralCategory UppercaseLetter or TitlecaseLetter.
See isUpperCase for a more intuitive predicate. Note that
unlike isUpperCase, isUpper does select title-case characters such as
'Dž' (U+01C5 Latin capital letter d with small letter z with caron) or
'ᾯ' (U+1FAF Greek capital letter omega with dasia and perispomeni and
prosgegrammeni).
Selects upper-case Unicode letter-like characters.
Note: this predicate selects characters with the Unicode property
Uppercase, which include letter-like characters such as:
'Ⓐ' (U+24B6 circled Latin capital letter A) and
'Ⅳ' (U+2163 Roman numeral four).
See isUpper for the legacy predicate. Note that
unlike isUpperCase, isUpper does select title-case characters such as
'Dž' (U+01C5 Latin capital letter d with small letter z with caron) or
'ᾯ' (U+1FAF Greek capital letter omega with dasia and perispomeni and
prosgegrammeni).
Selects lower-case alphabetic Unicode characters (letters).
Note: this predicate does not work for letter-like characters such as:
'ⓐ' (U+24D0 circled Latin small letter a) and
'ⅳ' (U+2173 small Roman numeral four). This is due to selecting only
characters with the GeneralCategory LowercaseLetter.
See isLowerCase for a more intuitive predicate.
Selects lower-case Unicode letter-like characters.
Note: this predicate selects characters with the Unicode property
Lowercase, which includes letter-like characters such as:
'ⓐ' (U+24D0 circled Latin small letter a) and
'ⅳ' (U+2173 small Roman numeral four).
See isLower for the legacy predicate.
Selects alphabetic Unicode characters (lower-case, upper-case and title-case letters, plus letters of caseless scripts and modifiers letters). This function is equivalent to isLetter.
This function returns True if its argument has one of the following GeneralCategorys, or False otherwise:
These classes are defined in the Unicode Character Database, part of the Unicode standard. The same document defines what is and is not a "Letter".
Selects ASCII digits, i.e. '0'..'9'.
Selects ASCII octal digits, i.e. '0'..'7'.
Selects ASCII hexadecimal digits,
i.e. '0'..'9', 'a'..'f', 'A'..'F'.
Selects alphabetic or numeric Unicode characters.
Note that numeric digits outside the ASCII range, as well as numeric
characters which aren't digits, are selected by this function but not by
isDigit. Such characters may be part of identifiers but are not used by
the printer and reader to represent numbers, e.g., Roman numerals like ,
full-width digits like V'1' (aka '65297').
This function returns True if its argument has one of the following GeneralCategorys, or False otherwise:
Selects Unicode punctuation characters, including various kinds of connectors, brackets and quotes.
This function returns True if its argument has one of the following GeneralCategorys, or False otherwise:
These classes are defined in the Unicode Character Database, part of the Unicode standard. The same document defines what is and is not a "Punctuation".
Examples
Basic usage:
isPunctuation 'a'FalseisPunctuation '7'FalseisPunctuation '♥'FalseisPunctuation '"'TrueisPunctuation '?'TrueisPunctuation '—'True
Selects Unicode symbol characters, including mathematical and currency symbols.
This function returns True if its argument has one of the following GeneralCategorys, or False otherwise:
These classes are defined in the Unicode Character Database, part of the Unicode standard. The same document defines what is and is not a "Symbol".
Examples
Basic usage:
isSymbol 'a'FalseisSymbol '6'FalseisSymbol '='True
The definition of "math symbol" may be a little counter-intuitive depending on one's background:
isSymbol '+'TrueisSymbol '-'False
Convert a letter to the corresponding upper-case letter, if any. Any other character is returned unchanged.
Convert a letter to the corresponding lower-case letter, if any. Any other character is returned unchanged.
Convert a letter to the corresponding title-case or upper-case letter, if any. (Title case differs from upper case only for a small number of ligature letters.) Any other character is returned unchanged.