Commit 459fb7bc authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

isCoVarType should look at the *representation* type,

rather than using isPredTy!  In Core land, a PredTy
and its representation type are synonymous.
parent 1bcd32b8
......@@ -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}
......
......@@ -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.
%************************************************************************
%* *
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment