Merge commit
authorSimon Peyton Jones <simonpj@microsoft.com>
Wed, 4 May 2011 12:26:30 +0000 (13:26 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Wed, 4 May 2011 12:26:30 +0000 (13:26 +0100)
compiler/basicTypes/DataCon.lhs
compiler/types/OptCoercion.lhs
compiler/types/TypeRep.lhs

index fae899d..5e35984 100644 (file)
@@ -300,7 +300,7 @@ data DataCon
                -- the context constrains only universally quantified variables
                --      MkT :: forall a b. (a ~ b, Ord b) => a -> T a b
        dcOtherTheta :: ThetaType,  -- The other constraints in the data con's type
-                                   -- *other than* those in the dcEqSpec
+                                   -- other than those in the dcEqSpec
 
        dcStupidTheta :: ThetaType,     -- The context of the data type declaration 
                                        --      data Eq a => T a = ...
index 6d0f2b1..a93df03 100644 (file)
@@ -96,7 +96,9 @@ opt_co' env sym (TyConAppCo tc cos) = mkTyConAppCo tc (map (opt_co env sym) cos)
 opt_co' env sym (PredCo cos)        = mkPredCo (fmap (opt_co env sym) cos)\r
 opt_co' env sym (AppCo co1 co2)     = mkAppCo (opt_co env sym co1) (opt_co env sym co2)\r
 opt_co' env sym (ForAllCo tv co)    = case substTyVarBndr env tv of\r
-                                         (env', tv') -> ForAllCo tv' (opt_co env' sym co)\r
+                                         (env', tv') -> mkForAllCo tv' (opt_co env' sym co)\r
+     -- Use the "mk" functions to check for nested Refls\r
+\r
 opt_co' env sym (CoVarCo cv)\r
   | Just co <- lookupCoVar env cv\r
   = opt_co (zapCvSubstEnv env) sym co\r
index 0f400fa..db41403 100644 (file)
@@ -145,11 +145,12 @@ data Type
                        --    can appear as the right hand side of a type synonym.
 
   | FunTy
-       Type
+       Type            
        Type            -- ^ Special case of 'TyConApp': @TyConApp FunTyCon [t1, t2]@
+                       -- See Note [Equality-constrained types]
 
   | ForAllTy
-       TyCoVar         -- ^ Type *or* coercion variable; see Note [Equality-constrained types]
+       TyCoVar         -- Type variable
        Type            -- ^ A polymorphic type
 
   | PredTy
@@ -183,21 +184,9 @@ The type   forall ab. (a ~ [b]) => blah
 is encoded like this:
 
    ForAllTy (a:*) $ ForAllTy (b:*) $
-   ForAllTy (wild_co : a ~ [b]) $
+   FunTy (PredTy (EqPred a [b]) $
    blah
 
-That is, the "(a ~ [b]) =>" part is encode as a for-all
-type with a coercion variable that is never mentioned.
-
-We could instead have used a FunTy with an EqPred on the 
-left.  But we want 
-
-  * FunTy to mean RUN-TIME abstraction,
-    passing a real value at runtime, 
-
-  * ForAllTy to mean COMPILE-TIME abstraction, 
-    erased at runtime
-
 -------------------------------------
                Note [PredTy]