The character type Char represents Unicode codespace and its elements are code points as in definitions D9 and D10 of the Unicode Standard.
Character literals in Haskell are single-quoted: 'Q', 'Я' or 'Ω'.
To represent a single quote itself use '\'', and to represent a backslash
use '\\'. The full grammar can be found in the section 2.6 of the
Haskell 2010 Language Report.
To specify a character by its code point one can use decimal, hexadecimal
or octal notation: '\65', '\x41' and '\o101' are all alternative forms
of 'A'. The largest code point is '\x10ffff'.
There is a special escape syntax for ASCII control characters:
Escape | Alternatives | Meaning |
|---|---|---|
|
| null character |
|
| start of heading |
|
| start of text |
|
| end of text |
|
| end of transmission |
|
| enquiry |
|
| acknowledge |
|
,
| bell (alert) |
|
,
| backspace |
|
,
| horizontal tab |
|
,
| line feed (new line) |
|
,
| vertical tab |
|
,
| form feed |
|
,
| carriage return |
|
| shift out |
|
| shift in |
|
| data link escape |
|
| device control 1 |
|
| device control 2 |
|
| device control 3 |
|
| device control 4 |
|
| negative acknowledge |
|
| synchronous idle |
|
| end of transmission block |
|
| cancel |
|
| end of medium |
|
| substitute |
|
| escape |
|
| file separator |
|
| group separator |
|
| record separator |
|
| unit separator |
|
,
| space |
|
| delete |
Instances41Bounded, Enum, Data, Read, Ix, Storable, …
Bounded CharDefined in ghc-internal-9.1003.0 · GHC.Internal.EnumEnum CharDefined in ghc-internal-9.1003.0 · GHC.Internal.EnumEq CharDefined in ghc-prim-0.12.0 · GHC.ClassesData CharDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.DataOrd CharDefined in ghc-prim-0.12.0 · GHC.ClassesRead CharDefined in ghc-internal-9.1003.0 · GHC.Internal.ReadShow CharDefined in ghc-internal-9.1003.0 · GHC.Internal.ShowIx CharDefined in ghc-internal-9.1003.0 · GHC.Internal.IxStorable CharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.StorableIsChar CharDefined in base-4.20.2.0 · Text.PrintfPrintfArg CharDefined in base-4.20.2.0 · Text.PrintfNFData CharDefined in deepseq-1.5.0.0 · Control.DeepSeqPretty CharDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJClassPretty CharDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClassBinary CharDefined in binary-0.8.9.3 · Data.Binary.ClassHashable CharDefined in hashable-1.4.7.0 · Data.Hashable.ClassPrim CharDefined in primitive-0.9.1.0 · Data.Primitive.TypesUnbox CharDefined in vector-0.13.2.0 · Data.Vector.Unboxed.BaseDisplay CharDefined in rio-0.1.22.0 · RIO.Prelude.DisplayLift CharDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxTestCoercion SCharDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLitsTestEquality SCharDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLitsIArray UArray CharDefined in array-0.5.8.0 · Data.Array.BaseVector Vector CharDefined in vector-0.13.2.0 · Data.Vector.Unboxed.BaseMVector MVector CharDefined in vector-0.13.2.0 · Data.Vector.Unboxed.BaseMArray IOUArray Char IODefined in array-0.5.8.0 · Data.Array.IO.InternalsGeneric1 (URec Char)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsFoldable UCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableTraversable UCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.TraversableMArray (STUArray s) Char (ST s)Defined in array-0.5.8.0 · Data.Array.BaseFunctor (URec Char)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsEq (URec Char p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsOrd (URec Char p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsShow (URec Char p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (URec Char p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Genericstype Rep (URec Char p) = D1 ('MetaDataDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics"URec"
"GHC.Internal.Generics"
"ghc-internal"
'False) (C1 ('MetaCons"UChar"
'PrefixI 'True) (S1 ('MetaSel ('Just"uChar#"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UChar))type Rep1 (URec Char) = D1 ('MetaDataDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics"URec"
"GHC.Internal.Generics"
"ghc-internal"
'False) (C1 ('MetaCons"UChar"
'PrefixI 'True) (S1 ('MetaSel ('Just"uChar#"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UChar))data URec CharDefined in ghc-internal-9.1003.0 · GHC.Internal.GenericsUsed for marking occurrences of Char#
type Compare a b = CmpChar a bDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Orddata MVector s CharDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Basedata Vector CharDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base