Char package:constraints

Utilities for working with KnownChar constraints. This module is only available on GHC 9.2 or later.
Convert a character to its Unicode code point (cf. ord)
Convert a Unicode code point to a character (cf. chr)
Unsafely create an SChar value directly from a Char. Use this function with care:
  • The Char value must match the Char c encoded in the return type SChar c.
  • Be wary of using this function to create multiple values of type SChar T, where T is a type family that does not reduce (e.g., Any from GHC.Exts). If you do, GHC is liable to optimize away one of the values and replace it with the other during a common subexpression elimination pass. If the two values have different underlying Char values, this could be disastrous.