From: simonmar Date: Thu, 16 Nov 2000 09:51:31 +0000 (+0000) Subject: [project @ 2000-11-16 09:51:31 by simonmar] X-Git-Tag: Approximately_9120_patches~3332 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=f39a8725a7079848fc50557205a978005e8c8281;p=ghc-hetmet.git [project @ 2000-11-16 09:51:31 by simonmar] merge rev. 1.66.2.6 (add splitMethodTy) --- diff --git a/ghc/compiler/types/Type.lhs b/ghc/compiler/types/Type.lhs index bc2d94c..7ef2765 100644 --- a/ghc/compiler/types/Type.lhs +++ b/ghc/compiler/types/Type.lhs @@ -56,7 +56,7 @@ module Type ( TauType, RhoType, SigmaType, PredType(..), ThetaType, ClassPred, ClassContext, mkClassPred, getClassTys_maybe, ipName_maybe, classesOfPreds, - isTauTy, mkRhoTy, splitRhoTy, + isTauTy, mkRhoTy, splitRhoTy, splitMethodTy, mkSigmaTy, isSigmaTy, splitSigmaTy, getDFunTyKey, @@ -773,6 +773,26 @@ splitRhoTy ty = split ty ty [] split orig_ty ty ts = (reverse ts, orig_ty) \end{code} +The type of a method for class C is always of the form: + Forall a1..an. C a1..an => sig_ty +where sig_ty is the type given by the method's signature, and thus in general +is a ForallTy. At the point that splitMethodTy is called, it is expected +that the outer Forall has already been stripped off. splitMethodTy then +returns (C a1..an, sig_ty') where sig_ty' is sig_ty with any Notes or +Usages stripped off. + +\begin{code} +splitMethodTy :: Type -> (PredType, Type) +splitMethodTy ty = split ty + where + split (FunTy arg res) = case splitPredTy_maybe arg of + Just p -> (p, res) + Nothing -> panic "splitMethodTy" + split (NoteTy _ ty) = split ty + split (UsageTy _ ty) = split ty + split _ = panic "splitMethodTy" +\end{code} + isSigmaType returns true of any qualified type. It doesn't *necessarily* have any foralls. E.g.