From: simonpj Date: Mon, 22 Mar 1999 10:39:59 +0000 (+0000) Subject: [project @ 1999-03-22 10:39:59 by simonpj] X-Git-Tag: Approximately_9120_patches~6368 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=375c33b1a5085313b91329d396fa7d9c703bee46;p=ghc-hetmet.git [project @ 1999-03-22 10:39:59 by simonpj] 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. --- diff --git a/ghc/compiler/typecheck/TcMonoType.lhs b/ghc/compiler/typecheck/TcMonoType.lhs index 6eb256d..93fb0a5 100644 --- a/ghc/compiler/typecheck/TcMonoType.lhs +++ b/ghc/compiler/typecheck/TcMonoType.lhs @@ -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