\begin{code}
#include "HsVersions.h"
-module RnSource ( rnDecl, rnHsType ) where
+module RnSource ( rnDecl, rnHsType, rnHsSigType ) where
+IMPORT_1_3(List(partition))
IMP_Ubiq()
+
+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ <= 201
IMPORT_DELOOPER(RnLoop) -- *check* the RnPass/RnExpr/RnBinds loop-breaking
+#else
+import {-# SOURCE #-} RnExpr
+#endif
import HsSyn
import HsDecls ( HsIdInfo(..) )
import RnBinds ( rnTopBinds, rnMethodBinds )
import RnEnv ( bindTyVarsRn, lookupBndrRn, lookupOccRn, lookupImplicitOccRn, bindLocalsRn,
- lookupOptionalOccRn, newSysName, newDfunName,
+ newSysName, newDfunName, checkDupOrQualNames, checkDupNames,
listType_RDR, tupleType_RDR )
import RnMonad
import Lex ( isLexCon )
import CoreUnfold ( Unfolding(..), SimpleUnfolding )
import MagicUFs ( MagicUnfoldingFun )
-import PrelInfo ( derivingOccurrences, evalClass_RDR, numClass_RDR )
+import PrelInfo ( derivingOccurrences, evalClass_RDR, numClass_RDR, allClass_NAME )
import ListSetOps ( unionLists, minusList )
import Maybes ( maybeToBool, catMaybes )
import Bag ( emptyBag, unitBag, consBag, unionManyBags, unionBags, listToBag, bagToList )
-import Outputable ( Outputable(..){-instances-} )
---import PprStyle -- ToDo:rm
+import Outputable ( PprStyle(..), Outputable(..){-instances-} )
import Pretty
import SrcLoc ( SrcLoc )
--- import TyCon ( TyCon{-instance NamedThing-} )
import Unique ( Unique )
import UniqSet ( SYN_IE(UniqSet) )
import UniqFM ( UniqFM, lookupUFM )
-import Util ( isIn, isn'tIn, thenCmp, removeDups, cmpPString,
- panic, assertPanic{- , pprTrace ToDo:rm-} )
+import Util
+IMPORT_1_3(List(nub))
\end{code}
rnDecl `renames' declarations.
= pushSrcLocRn loc $
lookupBndrRn name `thenRn` \ name' ->
rnHsType ty `thenRn` \ ty' ->
-
- -- Get the pragma info, unless we should ignore it
- (if opt_IgnoreIfacePragmas then
- returnRn []
- else
- mapRn rnIdInfo id_infos
- ) `thenRn` \ id_infos' ->
-
+ -- Get the pragma info (if any).
+ setModeRn (InterfaceMode Optional) $
+ -- In all the rest of the signature we read in optional mode,
+ -- so that (a) we don't die
+ mapRn rnIdInfo id_infos `thenRn` \ id_infos' ->
returnRn (SigD (IfaceSig name' ty' id_infos' loc))
\end{code}
checks at the same time.
\begin{code}
-rnDecl (TyD (TyData context tycon tyvars condecls derivings pragmas src_loc))
- = pushSrcLocRn src_loc $
- lookupBndrRn tycon `thenRn` \ tycon' ->
- bindTyVarsRn "data declaration" tyvars $ \ tyvars' ->
- rnContext context `thenRn` \ context' ->
- mapRn rnConDecl condecls `thenRn` \ condecls' ->
- rnDerivs derivings `thenRn` \ derivings' ->
- ASSERT(isNoDataPragmas pragmas)
- returnRn (TyD (TyData context' tycon' tyvars' condecls' derivings' noDataPragmas src_loc))
-
-rnDecl (TyD (TyNew context tycon tyvars condecl derivings pragmas src_loc))
+rnDecl (TyD (TyData new_or_data context tycon tyvars condecls derivings pragmas src_loc))
= pushSrcLocRn src_loc $
- lookupBndrRn tycon `thenRn` \ tycon' ->
- bindTyVarsRn "newtype declaration" tyvars $ \ tyvars' ->
- rnContext context `thenRn` \ context' ->
- rnConDecl condecl `thenRn` \ condecl' ->
- rnDerivs derivings `thenRn` \ derivings' ->
+ lookupBndrRn tycon `thenRn` \ tycon' ->
+ bindTyVarsRn data_doc tyvars $ \ tyvars' ->
+ rnContext context `thenRn` \ context' ->
+ checkDupOrQualNames data_doc con_names `thenRn_`
+ mapRn rnConDecl condecls `thenRn` \ condecls' ->
+ rnDerivs derivings `thenRn` \ derivings' ->
ASSERT(isNoDataPragmas pragmas)
- returnRn (TyD (TyNew context' tycon' tyvars' condecl' derivings' noDataPragmas src_loc))
+ returnRn (TyD (TyData new_or_data context' tycon' tyvars' condecls' derivings' noDataPragmas src_loc))
+ where
+ data_doc sty = text "the data type declaration for" <+> ppr sty tycon
+ con_names = map conDeclName condecls
rnDecl (TyD (TySynonym name tyvars ty src_loc))
= pushSrcLocRn src_loc $
lookupBndrRn name `thenRn` \ name' ->
- bindTyVarsRn "type declaration" tyvars $ \ tyvars' ->
+ bindTyVarsRn syn_doc tyvars $ \ tyvars' ->
rnHsType ty `thenRn` \ ty' ->
returnRn (TyD (TySynonym name' tyvars' ty' src_loc))
+ where
+ syn_doc sty = text "the declaration for type synonym" <+> ppr sty name
\end{code}
%*********************************************************
\begin{code}
rnDecl (ClD (ClassDecl context cname tyvar sigs mbinds pragmas src_loc))
= pushSrcLocRn src_loc $
- bindTyVarsRn "class declaration" [tyvar] $ \ [tyvar'] ->
- rnContext context `thenRn` \ context' ->
- lookupBndrRn cname `thenRn` \ cname' ->
- mapRn (rn_op cname' (getTyVarName tyvar')) sigs `thenRn` \ sigs' ->
+ bindTyVarsRn cls_doc [tyvar] ( \ [tyvar'] ->
+ rnContext context `thenRn` \ context' ->
+ lookupBndrRn cname `thenRn` \ cname' ->
+
+ -- Check the signatures
+ checkDupOrQualNames sig_doc sig_names `thenRn_`
+ mapRn (rn_op cname' (getTyVarName tyvar')) sigs `thenRn` \ sigs' ->
+ returnRn (tyvar', context', cname', sigs')
+ ) `thenRn` \ (tyvar', context', cname', sigs') ->
+
+ -- Check the methods
+ checkDupOrQualNames meth_doc meth_names `thenRn_`
rnMethodBinds mbinds `thenRn` \ mbinds' ->
+
+ -- Typechecker is responsible for checking that we only
+ -- give default-method bindings for things in this class.
+ -- The renamer *could* check this for class decls, but can't
+ -- for instance decls.
+
ASSERT(isNoClassPragmas pragmas)
returnRn (ClD (ClassDecl context' cname' tyvar' sigs' mbinds' NoClassPragmas src_loc))
where
+ cls_doc sty = text "the declaration for class" <+> ppr sty cname
+ sig_doc sty = text "the signatures for class" <+> ppr sty cname
+ meth_doc sty = text "the default-methods for class" <+> ppr sty cname
+
+ sig_names = [(op,locn) | ClassOpSig op _ _ locn <- sigs]
+ meth_names = bagToList (collectMonoBinders mbinds)
+
rn_op clas clas_tyvar sig@(ClassOpSig op _ ty locn)
= pushSrcLocRn locn $
- let
- dm_occ = prefixOccName SLIT("$m") (rdrNameOcc op)
- in
lookupBndrRn op `thenRn` \ op_name ->
- newSysName dm_occ Exported locn `thenRn` \ dm_name ->
- addOccurrenceName Optional dm_name `thenRn_`
+ rnHsSigType (\sty -> ppr sty op) ty `thenRn` \ new_ty ->
+
-- Call up interface info for default method, if such info exists
-
- rnHsType ty `thenRn` \ new_ty ->
+ let
+ dm_occ = prefixOccName SLIT("$m") (rdrNameOcc op)
+ in
+ newSysName dm_occ Exported locn `thenRn` \ dm_name ->
+ setModeRn (InterfaceMode Optional) (
+ addOccurrenceName dm_name
+ ) `thenRn_`
+
+ -- Checks.....
let
(ctxt, op_ty) = case new_ty of
HsForAllTy tvs ctxt op_ty -> (ctxt, op_ty)
op_ty_fvs = extractHsTyNames op_ty -- Includes tycons/classes but we
-- don't care about that
in
- -- check that class tyvar appears in op_ty
+ -- Check that class tyvar appears in op_ty
checkRn (clas_tyvar `elemNameSet` op_ty_fvs)
(classTyVarNotInOpTyErr clas_tyvar sig)
`thenRn_`
- -- check that class tyvar *doesn't* appear in the sig's context
- checkRn (not (clas_tyvar `elemNameSet` ctxt_fvs))
- (classTyVarInOpCtxtErr clas_tyvar sig)
- `thenRn_`
-
--- ASSERT(isNoClassOpPragmas pragmas)
returnRn (ClassOpSig op_name dm_name new_ty locn)
\end{code}
\begin{code}
rnDecl (InstD (InstDecl inst_ty mbinds uprags maybe_dfun src_loc))
= pushSrcLocRn src_loc $
- rnHsType inst_ty `thenRn` \ inst_ty' ->
+ rnHsSigType (\sty -> text "an instance decl") inst_ty `thenRn` \ inst_ty' ->
+
+
+ -- Rename the bindings
+ -- NB meth_names can be qualified!
+ checkDupNames meth_doc meth_names `thenRn_`
rnMethodBinds mbinds `thenRn` \ mbinds' ->
mapRn rn_uprag uprags `thenRn` \ new_uprags ->
newDfunName maybe_dfun src_loc `thenRn` \ dfun_name ->
- addOccurrenceName Compulsory dfun_name `thenRn_`
+ addOccurrenceName dfun_name `thenRn_`
-- The dfun is not optional, because we use its version number
-- to identify the version of the instance declaration
+ -- The typechecker checks that all the bindings are for the right class.
returnRn (InstD (InstDecl inst_ty' mbinds' new_uprags (Just dfun_name) src_loc))
where
+ meth_doc sty = text "the bindings in an instance declaration"
+ meth_names = bagToList (collectMonoBinders mbinds)
+
rn_uprag (SpecSig op ty using locn)
= pushSrcLocRn src_loc $
- lookupBndrRn op `thenRn` \ op_name ->
- rnHsType ty `thenRn` \ new_ty ->
- rn_using using `thenRn` \ new_using ->
+ lookupBndrRn op `thenRn` \ op_name ->
+ rnHsSigType (\sty -> ppr sty op) ty `thenRn` \ new_ty ->
+ rn_using using `thenRn` \ new_using ->
returnRn (SpecSig op_name new_ty new_using locn)
rn_uprag (InlineSig op locn)
\end{code}
\begin{code}
-rnConDecl :: RdrNameConDecl -> RnMS s RenamedConDecl
-
-rnConDecl (ConDecl name tys src_loc)
- = pushSrcLocRn src_loc $
- checkConName name `thenRn_`
- lookupBndrRn name `thenRn` \ new_name ->
- mapRn rnBangTy tys `thenRn` \ new_tys ->
- returnRn (ConDecl new_name new_tys src_loc)
+conDeclName :: RdrNameConDecl -> (RdrName, SrcLoc)
+conDeclName (ConDecl n _ _ l) = (n,l)
-rnConDecl (ConOpDecl ty1 op ty2 src_loc)
- = pushSrcLocRn src_loc $
- lookupBndrRn op `thenRn` \ new_op ->
- rnBangTy ty1 `thenRn` \ new_ty1 ->
+rnConDecl :: RdrNameConDecl -> RnMS s RenamedConDecl
+rnConDecl (ConDecl name cxt details locn)
+ = pushSrcLocRn locn $
+ checkConName name `thenRn_`
+ lookupBndrRn name `thenRn` \ new_name ->
+ rnConDetails name locn details `thenRn` \ new_details ->
+ rnContext cxt `thenRn` \ new_context ->
+ returnRn (ConDecl new_name new_context new_details locn)
+
+rnConDetails con locn (VanillaCon tys)
+ = mapRn rnBangTy tys `thenRn` \ new_tys ->
+ returnRn (VanillaCon new_tys)
+
+rnConDetails con locn (InfixCon ty1 ty2)
+ = rnBangTy ty1 `thenRn` \ new_ty1 ->
rnBangTy ty2 `thenRn` \ new_ty2 ->
- returnRn (ConOpDecl new_ty1 new_op new_ty2 src_loc)
+ returnRn (InfixCon new_ty1 new_ty2)
-rnConDecl (NewConDecl name ty src_loc)
- = pushSrcLocRn src_loc $
- checkConName name `thenRn_`
- lookupBndrRn name `thenRn` \ new_name ->
- rnHsType ty `thenRn` \ new_ty ->
- returnRn (NewConDecl new_name new_ty src_loc)
+rnConDetails con locn (NewCon ty)
+ = rnHsType ty `thenRn` \ new_ty ->
+ returnRn (NewCon new_ty)
-rnConDecl (RecConDecl name fields src_loc)
- = pushSrcLocRn src_loc $
- lookupBndrRn name `thenRn` \ new_name ->
- mapRn rnField fields `thenRn` \ new_fields ->
- returnRn (RecConDecl new_name new_fields src_loc)
+rnConDetails con locn (RecCon fields)
+ = checkDupOrQualNames fld_doc field_names `thenRn_`
+ mapRn rnField fields `thenRn` \ new_fields ->
+ returnRn (RecCon new_fields)
+ where
+ fld_doc sty = text "the fields of constructor" <> ppr sty con
+ field_names = [(fld, locn) | (flds, _) <- fields, fld <- flds]
rnField (names, ty)
= mapRn lookupBndrRn names `thenRn` \ new_names ->
%*********************************************************
\begin{code}
-rnHsType :: RdrNameHsType -> RnMS s RenamedHsType
+rnHsSigType :: (PprStyle -> Doc) -> RdrNameHsType -> RnMS s RenamedHsType
+ -- rnHsSigType is used for source-language type signatures,
+ -- which use *implicit* universal quantification.
+
+-- Given the signature C => T we universally quantify over FV(T) \ {in-scope-tyvars}
+--
+-- We insist that the universally quantified type vars is a superset of FV(C)
+-- It follows that FV(T) is a superset of FV(C), so that the context constrains
+-- no type variables that don't appear free in the tau-type part.
+
+rnHsSigType doc_str full_ty@(HsPreForAllTy ctxt ty) -- From source code (no kinds on tyvars)
+ = getNameEnv `thenRn` \ name_env ->
+ let
+ mentioned_tyvars = extractHsTyVars ty
+ forall_tyvars = filter (not . in_scope) mentioned_tyvars
+ in_scope tv = maybeToBool (lookupFM name_env tv)
+
+ constrained_tyvars = nub (concat (map (extractHsTyVars . snd) ctxt))
+ constrained_and_in_scope = filter in_scope constrained_tyvars
+ constrained_and_not_mentioned = filter (not . (`elem` mentioned_tyvars)) constrained_tyvars
-rnHsType (HsForAllTy tvs ctxt ty)
+ -- Zap the context if there's a problem, to avoid duplicate error message.
+ ctxt' | null constrained_and_in_scope && null constrained_and_not_mentioned = ctxt
+ | otherwise = []
+ in
+ checkRn (null constrained_and_in_scope)
+ (ctxtErr1 sig_doc constrained_and_in_scope) `thenRn_`
+ checkRn (null constrained_and_not_mentioned)
+ (ctxtErr2 sig_doc constrained_and_not_mentioned ty) `thenRn_`
+
+ (bindTyVarsRn sig_doc (map UserTyVar forall_tyvars) $ \ new_tyvars ->
+ rnContext ctxt' `thenRn` \ new_ctxt ->
+ rnHsType ty `thenRn` \ new_ty ->
+ returnRn (HsForAllTy new_tyvars new_ctxt new_ty)
+ )
+ where
+ sig_doc sty = text "the type signature for" <+> doc_str sty
+
+
+rnHsSigType doc_str other_ty = rnHsType other_ty
+
+rnHsType :: RdrNameHsType -> RnMS s RenamedHsType
+rnHsType (HsForAllTy tvs ctxt ty) -- From an interface file (tyvars may be kinded)
= rn_poly_help tvs ctxt ty
-rnHsType full_ty@(HsPreForAllTy ctxt ty)
+rnHsType full_ty@(HsPreForAllTy ctxt ty) -- A (context => ty) embedded in a type.
+ -- Universally quantify over tyvars in context
= getNameEnv `thenRn` \ name_env ->
let
- mentioned_tyvars = extractHsTyVars full_ty
- forall_tyvars = filter not_in_scope mentioned_tyvars
- not_in_scope tv = case lookupFM name_env tv of
- Nothing -> True
- Just _ -> False
+ forall_tyvars = foldr unionLists [] (map (extractHsTyVars . snd) ctxt)
in
rn_poly_help (map UserTyVar forall_tyvars) ctxt ty
rnHsType ty `thenRn` \ ty' ->
returnRn (MonoDictTy clas' ty')
-
rn_poly_help :: [HsTyVar RdrName] -- Universally quantified tyvars
-> RdrNameContext
-> RdrNameHsType
-> RnMS s RenamedHsType
-
rn_poly_help tyvars ctxt ty
- = bindTyVarsRn "type signature" tyvars $ \ new_tyvars ->
+ = bindTyVarsRn sig_doc tyvars $ \ new_tyvars ->
rnContext ctxt `thenRn` \ new_ctxt ->
rnHsType ty `thenRn` \ new_ty ->
returnRn (HsForAllTy new_tyvars new_ctxt new_ty)
+ where
+ sig_doc sty = text "a nested for-all type"
\end{code}
= mapRn rn_ctxt ctxt `thenRn` \ result ->
let
(_, dup_asserts) = removeDups cmp_assert result
+ (alls, theta) = partition (\(c,_) -> c == allClass_NAME) result
+ non_tyvar_alls = [(c,t) | (c,t) <- alls, not (is_tyvar t)]
in
- -- If this isn't an error, then it ought to be:
- mapRn (addWarnRn . dupClassAssertWarn result) dup_asserts `thenRn_`
- returnRn result
+
+ -- Check for duplicate assertions
+ -- If this isn't an error, then it ought to be:
+ mapRn (addWarnRn . dupClassAssertWarn theta) dup_asserts `thenRn_`
+
+ -- Check for All constraining a non-type-variable
+ mapRn (addWarnRn . allOfNonTyVar) non_tyvar_alls `thenRn_`
+
+ -- Done. Return a theta omitting all the "All" constraints.
+ -- They have done done their work by ensuring that we universally
+ -- quantify over their tyvar.
+ returnRn theta
where
rn_ctxt (clas, ty)
- = lookupOccRn clas `thenRn` \ clas_name ->
+ = -- Mini hack here. If the class is our pseudo-class "All",
+ -- then we don't want to record it as an occurrence, otherwise
+ -- we try to slurp it in later and it doesn't really exist at all.
+ -- Easiest thing is simply not to put it in the occurrence set.
+ lookupBndrRn clas `thenRn` \ clas_name ->
+ (if clas_name /= allClass_NAME then
+ addOccurrenceName clas_name
+ else
+ returnRn clas_name
+ ) `thenRn_`
rnHsType ty `thenRn` \ ty' ->
returnRn (clas_name, ty')
cmp_assert (c1,ty1) (c2,ty2)
= (c1 `cmp` c2) `thenCmp` (cmpHsType cmp ty1 ty2)
+
+ is_tyvar (MonoTyVar _) = True
+ is_tyvar other = False
\end{code}
= rnStrict strict `thenRn` \ strict' ->
returnRn (HsStrictness strict')
-rnIdInfo (HsUnfold expr) = rnCoreExpr expr `thenRn` \ expr' ->
- returnRn (HsUnfold expr')
+rnIdInfo (HsUnfold inline expr) = rnCoreExpr expr `thenRn` \ expr' ->
+ returnRn (HsUnfold inline expr')
rnIdInfo (HsArity arity) = returnRn (HsArity arity)
rnIdInfo (HsUpdate update) = returnRn (HsUpdate update)
rnIdInfo (HsFBType fb) = returnRn (HsFBType fb)
rnIdInfo (HsArgUsage au) = returnRn (HsArgUsage au)
rnIdInfo (HsDeforest df) = returnRn (HsDeforest df)
-rnStrict (StrictnessInfo demands (Just worker))
- = lookupOptionalOccRn worker `thenRn` \ worker' ->
- returnRn (StrictnessInfo demands (Just worker'))
+rnStrict (StrictnessInfo demands (Just (worker,cons)))
+ -- The sole purpose of the "cons" field is so that we can mark the constructors
+ -- needed to build the wrapper as "needed", so that their data type decl will be
+ -- slurped in. After that their usefulness is o'er, so we just put in the empty list.
+ = lookupOccRn worker `thenRn` \ worker' ->
+ mapRn lookupOccRn cons `thenRn_`
+ returnRn (StrictnessInfo demands (Just (worker',[])))
-- Boring, but necessary for the type checker.
rnStrict (StrictnessInfo demands Nothing) = returnRn (StrictnessInfo demands Nothing)
\begin{code}
rnCoreExpr (UfVar v)
- = lookupOptionalOccRn v `thenRn` \ v' ->
+ = lookupOccRn v `thenRn` \ v' ->
returnRn (UfVar v')
rnCoreExpr (UfLit lit) = returnRn (UfLit lit)
rnCoreExpr (UfCon con args)
- = lookupOptionalOccRn con `thenRn` \ con' ->
+ = lookupOccRn con `thenRn` \ con' ->
mapRn rnCoreArg args `thenRn` \ args' ->
returnRn (UfCon con' args')
\end{code}
\begin{code}
-rnCoreArg (UfVarArg v) = lookupOptionalOccRn v `thenRn` \ v' -> returnRn (UfVarArg v')
-rnCoreArg (UfUsageArg u) = lookupOptionalOccRn u `thenRn` \ u' -> returnRn (UfUsageArg u')
+rnCoreArg (UfVarArg v) = lookupOccRn v `thenRn` \ v' -> returnRn (UfVarArg v')
+rnCoreArg (UfUsageArg u) = lookupOccRn u `thenRn` \ u' -> returnRn (UfUsageArg u')
rnCoreArg (UfTyArg ty) = rnHsType ty `thenRn` \ ty' -> returnRn (UfTyArg ty')
rnCoreArg (UfLitArg lit) = returnRn (UfLitArg lit)
rnCoreDefault deflt `thenRn` \ deflt' ->
returnRn (UfAlgAlts alts' deflt')
where
- rn_alt (con, bndrs, rhs) = lookupOptionalOccRn con `thenRn` \ con' ->
+ rn_alt (con, bndrs, rhs) = lookupOccRn con `thenRn` \ con' ->
bindLocalsRn "unfolding alt" bndrs $ \ bndrs' ->
rnCoreExpr rhs `thenRn` \ rhs' ->
returnRn (con', bndrs', rhs')
rnCoreExpr rhs `thenRn` \ rhs' ->
returnRn (UfBindDefault bndr' rhs')
-rnCoercion (UfIn n) = lookupOptionalOccRn n `thenRn` \ n' -> returnRn (UfIn n')
-rnCoercion (UfOut n) = lookupOptionalOccRn n `thenRn` \ n' -> returnRn (UfOut n')
+rnCoercion (UfIn n) = lookupOccRn n `thenRn` \ n' -> returnRn (UfIn n')
+rnCoercion (UfOut n) = lookupOccRn n `thenRn` \ n' -> returnRn (UfOut n')
rnCorePrim (UfOtherOp op)
- = lookupOptionalOccRn op `thenRn` \ op' ->
+ = lookupOccRn op `thenRn` \ op' ->
returnRn (UfOtherOp op')
rnCorePrim (UfCCallOp str casm gc arg_tys res_ty)
\begin{code}
derivingNonStdClassErr clas sty
- = ppCat [ppPStr SLIT("non-standard class in deriving:"), ppr sty clas]
+ = hsep [ptext SLIT("non-standard class"), ppr sty clas, ptext SLIT("in deriving clause")]
classTyVarNotInOpTyErr clas_tyvar sig sty
- = ppHang (ppBesides [ppPStr SLIT("Class type variable `"),
+ = hang (hsep [ptext SLIT("Class type variable"),
ppr sty clas_tyvar,
- ppPStr SLIT("' does not appear in method signature:")])
- 4 (ppr sty sig)
-
-classTyVarInOpCtxtErr clas_tyvar sig sty
- = ppHang (ppBesides [ ppPStr SLIT("Class type variable `"), ppr sty clas_tyvar,
- ppPStr SLIT("' present in method's local overloading context:")])
+ ptext SLIT("does not appear in method signature")])
4 (ppr sty sig)
dupClassAssertWarn ctxt dups sty
- = ppHang (ppBesides [ppPStr SLIT("Duplicate class assertion `"),
+ = hang (hcat [ptext SLIT("Duplicate class assertion `"),
ppr sty dups,
- ppPStr SLIT("' in context:")])
+ ptext SLIT("' in context:")])
4 (ppr sty ctxt)
badDataCon name sty
- = ppCat [ppPStr SLIT("Illegal data constructor name:"), ppr sty name]
+ = hsep [ptext SLIT("Illegal data constructor name:"), ppr sty name]
+
+allOfNonTyVar ty sty
+ = hsep [ptext SLIT("`All' applied to a non-type variable:"), ppr sty ty]
+
+ctxtErr1 doc tyvars sty
+ = hsep [ptext SLIT("Context constrains in-scope type variable(s)"),
+ hsep (punctuate comma (map (ppr sty) tyvars))]
+ $$
+ nest 4 (ptext SLIT("in") <+> doc sty)
+
+ctxtErr2 doc tyvars ty sty
+ = (ptext SLIT("Context constrains type variable(s)")
+ <+> hsep (punctuate comma (map (ppr sty) tyvars)))
+ $$
+ nest 4 (vcat [ptext SLIT("that do not appear in") <+> ppr sty ty,
+ ptext SLIT("in") <+> doc sty])
\end{code}
-
-
-
-
-
-=================== OLD STUFF ======================
-
-%*********************************************************
-%* *
-\subsection{SPECIALIZE data pragmas}
-%* *
-%*********************************************************
-
-\begin{pseudocode}
-rnSpecDataSig :: RdrNameSpecDataSig
- -> RnMS s RenamedSpecDataSig
-
-rnSpecDataSig (SpecDataSig tycon ty src_loc)
- = pushSrcLocRn src_loc $
- let
- tyvars = filter extractHsTyNames ty
- in
- mkTyVarNamesEnv src_loc tyvars `thenRn` \ (tv_env,_) ->
- lookupOccRn tycon `thenRn` \ tycon' ->
- rnHsType tv_env ty `thenRn` \ ty' ->
- returnRn (SpecDataSig tycon' ty' src_loc)
-
-\end{pseudocode}
-
-%*********************************************************
-%* *
-\subsection{@SPECIALIZE instance@ user-pragmas}
-%* *
-%*********************************************************
-
-\begin{pseudocode}
-rnSpecInstSig :: RdrNameSpecInstSig
- -> RnMS s RenamedSpecInstSig
-
-rnSpecInstSig (SpecInstSig clas ty src_loc)
- = pushSrcLocRn src_loc $
- let
- tyvars = extractHsTyNames is_tyvar_name ty
- in
- mkTyVarNamesEnv src_loc tyvars `thenRn` \ (tv_env,_) ->
- lookupOccRn clas `thenRn` \ new_clas ->
- rnHsType tv_env ty `thenRn` \ new_ty ->
- returnRn (SpecInstSig new_clas new_ty src_loc)
-\end{pseudocode}