-XImpredicativeTypes implies -XRankNTypes, and improve error msg in TcMType
authorsimonpj@microsoft.com <unknown>
Wed, 31 Dec 2008 15:25:17 +0000 (15:25 +0000)
committersimonpj@microsoft.com <unknown>
Wed, 31 Dec 2008 15:25:17 +0000 (15:25 +0000)
If you are going for impredicative types you almost certainly want RankN
too. The change to TcMType improves the error when you say
     T (forall a. blah)
where T is a type synonym.  This doesn't necessarily need impredicativity,
if you have LiberalTypeSynonyms.

compiler/main/DynFlags.hs
compiler/typecheck/TcMType.lhs

index d04dade..f67bb4e 100644 (file)
@@ -1792,6 +1792,7 @@ impliedFlags
 
     , (Opt_ScopedTypeVariables, Opt_RelaxedPolyRec)  -- Ditto for scoped type variables; see
                                                      --      Note [Scoped tyvars] in TcBinds
+    , (Opt_ImpredicativeTypes,  Opt_RankNTypes)
   ]
 
 glasgowExtsFlags :: [DynFlag]
index 6de3dd2..75ce6c9 100644 (file)
@@ -1066,6 +1066,7 @@ checkValidMonoType ty = check_mono_type MustBeMonoType ty
 data Rank = ArbitraryRank        -- Any rank ok
           | MustBeMonoType       -- Monotype regardless of flags
          | TyConArgMonoType      -- Monotype but could be poly if -XImpredicativeTypes
+         | SynArgMonoType        -- Monotype but could be poly if -XLiberalTypeSynonyms
           | Rank Int             -- Rank n, but could be more with -XRankNTypes
 
 decRank :: Rank -> Rank                  -- Function arguments
@@ -1139,7 +1140,7 @@ check_type rank ubx_tup ty@(TyConApp tc tys)
        ; liberal <- doptM Opt_LiberalTypeSynonyms
        ; if not liberal || isOpenSynTyCon tc then
                -- For H98 and synonym families, do check the type args
-               mapM_ (check_mono_type TyConArgMonoType) tys
+               mapM_ (check_mono_type SynArgMonoType) tys
 
          else  -- In the liberal case (only for closed syns), expand then check
          case tcView ty of   
@@ -1216,6 +1217,7 @@ forAllTyErr rank ty
     suggestion = case rank of
                   Rank _ -> ptext (sLit "Perhaps you intended to use -XRankNTypes or -XRank2Types")
                   TyConArgMonoType -> ptext (sLit "Perhaps you intended to use -XImpredicativeTypes")
+                  SynArgMonoType -> ptext (sLit "Perhaps you intended to use -XLiberalTypeSynonyms")
                   _ -> empty      -- Polytype is always illegal
 
 unliftedArgErr, ubxArgTyErr :: Type -> SDoc