diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/users_guide/9.2.1-notes.rst | 13 | ||||
-rw-r--r-- | docs/users_guide/exts/type_literals.rst | 10 |
2 files changed, 17 insertions, 6 deletions
diff --git a/docs/users_guide/9.2.1-notes.rst b/docs/users_guide/9.2.1-notes.rst index 1e73770c5d..a51875d3f4 100644 --- a/docs/users_guide/9.2.1-notes.rst +++ b/docs/users_guide/9.2.1-notes.rst @@ -166,3 +166,16 @@ Runtime system The ``Numeric`` module recieves ``showBin`` and ``readBin`` to show and read integer numbers in binary. +- ``Char`` gets type-level support by analogy with strings and natural numbers. + We extend the ``GHC.TypeLits`` module with these built-in type-families: :: + + type family CmpChar (a :: Char) (b :: Char) :: Ordering + type family ConsSymbol (a :: Char) (b :: Symbol) :: Symbol + type family UnconsSymbol (a :: Symbol) :: Maybe (Char, Symbol) + + and with the type class ``KnownChar`` (and such additional functions as ``charVal`` and ``charVal'``): :: + + class KnownChar (n :: Char) + + charVal :: forall n proxy. KnownChar n => proxy n -> Char + charVal' :: forall n. KnownChar n => Proxy# n -> Char diff --git a/docs/users_guide/exts/type_literals.rst b/docs/users_guide/exts/type_literals.rst index 202577668d..c019426444 100644 --- a/docs/users_guide/exts/type_literals.rst +++ b/docs/users_guide/exts/type_literals.rst @@ -3,11 +3,11 @@ Type-Level Literals =================== -GHC supports numeric and string literals at the type level, giving +GHC supports numeric, string, and character literals at the type level, giving convenient access to a large number of predefined type-level constants. -Numeric literals are of kind ``Natural``, while string literals are of kind -``Symbol``. This feature is enabled by the :extension:`DataKinds` language -extension. +Numeric literals are of kind ``Natural``, string literals are of kind ``Symbol``, +and character literals are of kind ``Char``. +This feature is enabled by the :extension:`DataKinds` language extension. The kinds of the literals and all other low-level operations for this feature are defined in modules ``GHC.TypeLits`` and ``GHC.TypeNats``. @@ -127,5 +127,3 @@ the type level: GHC.TypeLits> natVal (lg (Proxy :: Proxy 2) (Proxy :: Proxy 8)) 3 - - |