[commit: base] type-nats: Change the representation of singletons from Integer to Word. (1eba0a9)
Iavor Diatchki
diatchki at galois.com
Fri Dec 30 04:27:23 CET 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : type-nats
http://hackage.haskell.org/trac/ghc/changeset/1eba0a92e84b26100928b61497759981a4b5450c
>---------------------------------------------------------------
commit 1eba0a92e84b26100928b61497759981a4b5450c
Author: Iavor S. Diatchki <iavor.diatchki at gmail.com>
Date: Thu Dec 29 19:27:02 2011 -0800
Change the representation of singletons from Integer to Word.
This is---probably---just temporary. For details, take a look at
comment on case "EvInteger" in function "dsEvTerm" in "deSugar/DsBinds"
>---------------------------------------------------------------
GHC/TypeNats.hs | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/GHC/TypeNats.hs b/GHC/TypeNats.hs
index e86c4b6..05b1178 100644
--- a/GHC/TypeNats.hs
+++ b/GHC/TypeNats.hs
@@ -17,7 +17,7 @@ module GHC.TypeNats
, (:<=), (:+), (:*), (:^)
) where
-import GHC.Integer(Integer)
+import GHC.Word(Word)
-- | This is the *kind* of type-level natural numbers.
data Nat
@@ -38,13 +38,19 @@ type family (m :: Nat) :^ (n :: Nat) :: Nat
-- | The type @NatS n@ is m \"singleton\" type containing only the value @n at .
-- (Technically, there is also a bottom element).
-- This type relates type-level naturals to run-time values.
-newtype NatS (n :: Nat) = NatS Integer
+-- NOTE: For the moment we support only singleton types that can fit in
+-- a 'Word'.
+newtype NatS (n :: Nat) = NatS Word
-- | The class 'NatI' provides a \"smart\" constructor for values
--- of type @Nat n at . There are built-in instances for all natural numbers.
+-- of type @Nat n at . There are built-in instances for all natural numbers
+-- that fit in a 'Word'. The 'Word' restriction can be lifted but that
+-- would require a bunch of code in "deSugar/DsBinds" to be monadified,
+-- because making integer expression is a monadic operation. Not hard,
+-- but not yet done.
--
-- NOTE: The instances for 'NatI' are provided directly by GHC.
--- The built-in instances use the integer corresponding to the instance
+-- The built-in instances use the number corresponding to the instance
-- as evidence. This works because of the following two details about GHC:
-- * The "dictionary" for classes with a single method is the method itself,
-- so GHC simply coerces the dictionary into the value, and
More information about the Cvs-libraries
mailing list