[project @ 1999-03-22 10:39:59 by simonpj]
authorsimonpj <unknown>
Mon, 22 Mar 1999 10:39:59 +0000 (10:39 +0000)
committersimonpj <unknown>
Mon, 22 Mar 1999 10:39:59 +0000 (10:39 +0000)
Fix the HsForAll case in TcMonoType.tc_type_kind so that it
permits types like

f :: forall a. Num a => (# a->a, a->a #)

Previously it insisted that the body of a for-all was a boxed
type, but 'f' makes perfect sense, and indeed occurs in interface
files as a result of CPR analysis.

ghc/compiler/typecheck/TcMonoType.lhs

index 6eb256d..93fb0a5 100644 (file)
@@ -155,9 +155,19 @@ tc_type_kind (MonoDictTy class_name tys)
 tc_type_kind (HsForAllTy (Just tv_names) context ty)
   = tcExtendTyVarScope tv_names                $ \ tyvars -> 
     tcContext context                  `thenTc` \ theta ->
-    tc_boxed_type ty                   `thenTc` \ tau ->
-               -- Body of a for-all is a boxed type!
-    returnTc (boxedTypeKind, mkSigmaTy tyvars theta tau)
+    case theta of
+       []    ->        -- No context, so propagate body type
+                tc_type_kind ty        `thenTc` \ (kind, tau) ->
+                returnTc (kind, mkSigmaTy tyvars [] tau)
+
+       other ->        -- Context; behave like a function type
+                       -- This matters.  Return-unboxed-tuple analysis can
+                       -- give overloaded functions like
+                       --      f :: forall a. Num a => (# a->a, a->a #)
+                       -- And we want these to get through the type checker
+
+                tc_type ty             `thenTc` \ tau ->
+                returnTc (boxedTypeKind, mkSigmaTy tyvars theta tau)
 \end{code}
 
 Help functions for type applications