diff options
author | Daniel Rogozin <daniel.rogozin@serokell.io> | 2020-05-27 13:35:24 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-02-06 09:26:51 -0500 |
commit | 7f3524efcbd58ca6837ec0ffca6ddd121d64e4de (patch) | |
tree | aa296d28ed6475799ef369b0608736afcb467495 /docs | |
parent | 640a3ece333d1b0d0af8f353c3e1df9dd0cb9ef3 (diff) | |
download | haskell-7f3524efcbd58ca6837ec0ffca6ddd121d64e4de.tar.gz |
The Char kind (#11342)
Co-authored-by: Rinat Stryungis <rinat.stryungis@serokell.io>
Implement GHC Proposal #387
* Parse char literals 'x' at the type level
* New built-in type families CmpChar, ConsSymbol, UnconsSymbol
* New KnownChar class (cf. KnownSymbol and KnownNat)
* New SomeChar type (cf. SomeSymbol and SomeNat)
* CharTyLit support in template-haskell
Updated submodules: binary, haddock.
Metric Decrease:
T5205
haddock.base
Metric Increase:
Naperian
T13035
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 - - |