Char package:base-prelude
The character type
Char is an enumeration whose values
represent Unicode (or equivalently ISO/IEC 10646) code points (i.e.
characters, see
http://www.unicode.org/ for details). This set
extends the ISO 8859-1 (Latin-1) character set (the first 256
characters), which is itself an extension of the ASCII character set
(the first 128 characters). A character literal in Haskell has type
Char.
To convert a
Char to or from the corresponding
Int value
defined by Unicode, use
toEnum and
fromEnum from the
Enum class respectively (or equivalently
ord and
chr).
An encoding in which Unicode code points are translated to bytes by
taking the code point modulo 256. When decoding, bytes are translated
directly into the equivalent code point.
This encoding never fails in either direction. However, encoding
discards information, so encode followed by decode is not the
identity.
Read a character from the standard input device (same as
hGetChar stdin).
Computation
hGetChar hdl reads a character from the
file or channel managed by
hdl, blocking until a character is
available.
This operation may fail with:
Computation
hPutChar hdl ch writes the character
ch to the file or channel managed by
hdl. Characters
may be buffered if buffering is enabled for
hdl.
This operation may fail with:
Read a string representation of a character, using Haskell
source-language escape conventions. For example:
lexLitChar "\\nHello" = [("\\n", "Hello")]
Makes a constructor for
Char.
Write a character to the standard output device (same as
hPutChar stdout).
Read a string representation of a character, using Haskell
source-language escape conventions, and convert it to the character
that it encodes. For example:
readLitChar "\\nHello" = [('\n', "Hello")]
utility function converting a
Char to a show function that
simply prepends the character unchanged.
Convert a character to a string using only printable characters, using
Haskell source-language escape conventions. For example:
showLitChar '\n' s = "\\n" ++ s