[commit: ghc] wip/generics-propeq: testing waters with indexed constructors (a665402)

git at git.haskell.org git at git.haskell.org
Sun Jun 29 11:29:44 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/generics-propeq
Link       : http://ghc.haskell.org/trac/ghc/changeset/a66540240a3c2dfe86c2ef5a0d335efe150aaf8f/ghc

>---------------------------------------------------------------

commit a66540240a3c2dfe86c2ef5a0d335efe150aaf8f
Author: Gabor Greif <ggreif at gmail.com>
Date:   Sun Jun 29 12:23:34 2014 +0200

    testing waters with indexed constructors
    
     * first index is the datatype context
     * second is the name of the constructor
    
    (Note: for these datatypes we cannot (easily) enumerate
     all the distinct constructors, so we specify the empty
     symbol, meaning an abstract constuctor (in 'gdiff' parlance))


>---------------------------------------------------------------

a66540240a3c2dfe86c2ef5a0d335efe150aaf8f
 libraries/base/GHC/Generics.hs | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/libraries/base/GHC/Generics.hs b/libraries/base/GHC/Generics.hs
index fd97ad8..7bb1ed0 100644
--- a/libraries/base/GHC/Generics.hs
+++ b/libraries/base/GHC/Generics.hs
@@ -546,7 +546,7 @@ module GHC.Generics  (
 -----------------------------------------------------------------------------
 
   -- * Datatype representation types
-    Dat,
+    Dat, Constr,
 
   -- * Generic representation types
     V1, U1(..), Par1(..), Rec1(..), K1(..), M1(..)
@@ -583,6 +583,8 @@ import Data.Proxy
 
 data Dat (mod :: Symbol) (name :: Symbol)
 
+data Constr ctx (name :: Symbol)
+
 -- | Void: used for datatypes without constructors
 data V1 p
 
@@ -758,7 +760,7 @@ deriving instance Generic1 ((,,,,,,) a b c d e f)
 --------------------------------------------------------------------------------
 
 -- Int
-data C_Int
+type C_Int = Constr (Dat "GHC.Int" "Int") ""
 
 instance Datatype (Dat "GHC.Int" "Int") where
   datatypeName _ = "Int"
@@ -774,7 +776,7 @@ instance Generic Int where
 
 
 -- Float
-data C_Float
+type C_Float = Constr (Dat "GHC.Float" "Float") ""
 
 instance Datatype (Dat "GHC.Float" "Float") where
   datatypeName _ = "Float"
@@ -790,7 +792,7 @@ instance Generic Float where
 
 
 -- Double
-data C_Double
+type C_Double = Constr (Dat "GHC.Float" "Double") ""
 
 instance Datatype (Dat "GHC.Float" "Double") where
   datatypeName _ = "Double"
@@ -806,7 +808,7 @@ instance Generic Double where
 
 
 -- Char
-data C_Char
+type C_Char = Constr (Dat "GHC.Base" "Char") ""
 
 instance Datatype (Dat "GHC.Base" "Char") where
   datatypeName _ = "Char"



More information about the ghc-commits mailing list