Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/459fb7bcb36bea9798486b74098e800b1d55139f

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

commit 459fb7bcb36bea9798486b74098e800b1d55139f
Author: Simon Peyton Jones <[email protected]>
Date:   Wed Aug 3 16:15:29 2011 +0100

    isCoVarType should look at the *representation* type,
    rather than using isPredTy!  In Core land, a PredTy
    and its representation type are synonymous.

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

 compiler/types/Coercion.lhs |    7 +++++--
 compiler/types/TypeRep.lhs  |   26 ++++----------------------
 2 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/compiler/types/Coercion.lhs b/compiler/types/Coercion.lhs
index db7f96f..cf458c7 100644
--- a/compiler/types/Coercion.lhs
+++ b/compiler/types/Coercion.lhs
@@ -99,7 +99,7 @@ import Outputable
 import Unique
 import Pair
 import TysPrim         ( eqPredPrimTyCon )
-import PrelNames       ( funTyConKey )
+import PrelNames       ( funTyConKey, eqPredPrimTyConKey )
 import Control.Applicative
 import Data.Traversable (traverse, sequenceA)
 import Control.Arrow (second)
@@ -279,7 +279,10 @@ isCoVar :: Var -> Bool
 isCoVar v = isCoVarType (varType v)
 
 isCoVarType :: Type -> Bool
-isCoVarType = isEqPredTy
+-- Don't rely on a PredTy; look at the representation type
+isCoVarType ty 
+  | Just tc <- tyConAppTyCon_maybe ty = tc `hasKey` eqPredPrimTyConKey
+  | otherwise                         = False
 \end{code}
 
 
diff --git a/compiler/types/TypeRep.lhs b/compiler/types/TypeRep.lhs
index e0a5670..c6568e2 100644
--- a/compiler/types/TypeRep.lhs
+++ b/compiler/types/TypeRep.lhs
@@ -155,11 +155,11 @@ data Type
 
   | PredTy
        PredType        -- ^ The type of evidence for a type predictate.
-                        -- Note that a @PredTy (EqPred _ _)@ can appear only 
as the kind
-                        -- of a coercion variable; never as the argument or 
result of a
-                        -- 'FunTy' (unlike the 'PredType' constructors 
'ClassP' or 'IParam')
+                       -- See Note [PredTy]
+                       -- By the time we are in Core-land, PredTys are
+                       -- synonymous with their representation
+                       -- (see Type.predTypeRep)
                        
-                       -- See Note [PredTy], and Note [Equality predicates]
   deriving (Data.Data, Data.Typeable)
 
 -- | The key type representing kinds in the compiler.
@@ -231,24 +231,6 @@ The predicate really does turn into a real extra argument 
to the
 function.  If the argument has type (PredTy p) then the predicate p is
 represented by evidence (a dictionary, for example, of type (predRepTy p).
 
-Note [Equality predicates]
-~~~~~~~~~~~~~~~~~~~~~~~~~~
-       forall a b. (a ~ S b) => a -> b
-could be represented by
-       ForAllTy a (ForAllTy b (FunTy (PredTy (EqPred a (S b))) ...))
-OR
-       ForAllTy a (ForAllTy b (ForAllTy (c::PredTy (EqPred a (S b))) ...))
-
-The latter is what we do.  (Unlike for class and implicit parameter
-constraints, which do use FunTy.)
-
-Reason:
-       * FunTy is always a *value* function
-       * ForAllTy is discarded at runtime
-
-We often need to make a "wildcard" (c::PredTy..).  We always use the same
-name (wildCoVarName), since it's not mentioned.
-
 
 %************************************************************************
 %*                                                                     *



_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to