X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Frename%2FRnTypes.lhs;h=227cce53569dd90f8cf6f704e163c0e18682bf74;hb=8c7c30b1221025c0cffb1f14d014078b6e3055fc;hp=4b6f799cf556139cb7c91f54cca66f65fae8ef18;hpb=98688c6e8fd33f31c51218cf93cbf03fe3a5e73d;p=ghc-hetmet.git diff --git a/ghc/compiler/rename/RnTypes.lhs b/ghc/compiler/rename/RnTypes.lhs index 4b6f799..227cce5 100644 --- a/ghc/compiler/rename/RnTypes.lhs +++ b/ghc/compiler/rename/RnTypes.lhs @@ -75,7 +75,7 @@ want a gratuitous knot. \begin{code} rnHsType :: SDoc -> RdrNameHsType -> RnM RenamedHsType -rnHsType doc (HsForAllTy Nothing ctxt ty) +rnHsType doc (HsForAllTy Implicit _ ctxt ty) -- Implicit quantifiction in source code (no kinds on tyvars) -- Given the signature C => T we universally quantify -- over FV(T) \ {in-scope-tyvars} @@ -89,9 +89,9 @@ rnHsType doc (HsForAllTy Nothing ctxt ty) -- class C a where { op :: a -> a } forall_tyvars = filter (not . (`elemLocalRdrEnv` name_env)) mentioned in - rnForAll doc (map UserTyVar forall_tyvars) ctxt ty + rnForAll doc Implicit (map UserTyVar forall_tyvars) ctxt ty -rnHsType doc (HsForAllTy (Just forall_tyvars) ctxt tau) +rnHsType doc (HsForAllTy Explicit forall_tyvars ctxt tau) -- Explicit quantification. -- Check that the forall'd tyvars are actually -- mentioned in the type, and produce a warning if not @@ -103,7 +103,7 @@ rnHsType doc (HsForAllTy (Just forall_tyvars) ctxt tau) warn_guys = filter (`notElem` mentioned) forall_tyvar_names in mappM_ (forAllWarn doc tau) warn_guys `thenM_` - rnForAll doc forall_tyvars ctxt tau + rnForAll doc Explicit forall_tyvars ctxt tau rnHsType doc (HsTyVar tyvar) = lookupOccRn tyvar `thenM` \ tyvar' -> @@ -167,11 +167,22 @@ rnHsTypes doc tys = mappM (rnHsType doc) tys \begin{code} -rnForAll doc forall_tyvars ctxt ty +rnForAll doc exp [] [] ty = rnHsType doc ty + -- One reason for this case is that a type like Int# + -- starts of as (HsForAllTy Nothing [] Int), in case + -- there is some quantification. Now that we have quantified + -- and discovered there are no type variables, it's nicer to turn + -- it into plain Int. If it were Int# instead of Int, we'd actually + -- get an error, because the body of a genuine for-all is + -- of kind *. + +rnForAll doc exp forall_tyvars ctxt ty = bindTyVarsRn doc forall_tyvars $ \ new_tyvars -> rnContext doc ctxt `thenM` \ new_ctxt -> rnHsType doc ty `thenM` \ new_ty -> - returnM (mkHsForAllTy (Just new_tyvars) new_ctxt new_ty) + returnM (HsForAllTy exp new_tyvars new_ctxt new_ty) + -- Retain the same implicit/explicit flag as before + -- so that we can later print it correctly \end{code}