summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2011-08-03 16:15:29 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2011-08-03 16:15:29 +0100
commit459fb7bcb36bea9798486b74098e800b1d55139f (patch)
treef777deba1c69be61476fbf92222f0514c2bcf9e8
parent1bcd32b8e0f252d3b830c961184dab9d8b61dba9 (diff)
downloadhaskell-459fb7bcb36bea9798486b74098e800b1d55139f.tar.gz
isCoVarType should look at the *representation* type,
rather than using isPredTy! In Core land, a PredTy and its representation type are synonymous.
-rw-r--r--compiler/types/Coercion.lhs7
-rw-r--r--compiler/types/TypeRep.lhs28
2 files changed, 10 insertions, 25 deletions
diff --git a/compiler/types/Coercion.lhs b/compiler/types/Coercion.lhs
index db7f96f0a7..cf458c7889 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 e0a567055a..c6568e280b 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], and Note [Equality predicates]
+ -- See Note [PredTy]
+ -- By the time we are in Core-land, PredTys are
+ -- synonymous with their representation
+ -- (see Type.predTypeRep)
+
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.
-
%************************************************************************
%* *