Inst(..), -- Visible only to TcSimplify
InstOrigin(..), OverloadedLit(..),
- LIE(..), emptyLIE, unitLIE, plusLIE, consLIE, zonkLIE, plusLIEs,
+ SYN_IE(LIE), emptyLIE, unitLIE, plusLIE, consLIE, zonkLIE, plusLIEs,
- InstanceMapper(..),
+ SYN_IE(InstanceMapper),
newDicts, newDictsAtLoc, newMethod, newMethodWithGivenTy, newOverloadedLit,
) where
IMP_Ubiq()
+IMPORT_1_3(Ratio(Rational))
-import HsSyn ( HsLit(..), HsExpr(..), HsBinds,
- InPat, OutPat, Stmt, Qualifier, Match,
- ArithSeqInfo, PolyType, Fake )
-import RnHsSyn ( RenamedArithSeqInfo(..), RenamedHsExpr(..) )
-import TcHsSyn ( TcIdOcc(..), TcExpr(..), TcIdBndr(..),
+import HsSyn ( HsLit(..), HsExpr(..), HsBinds, Fixity,
+ InPat, OutPat, Stmt, DoOrListComp, Match,
+ ArithSeqInfo, HsType, Fake )
+import RnHsSyn ( SYN_IE(RenamedArithSeqInfo), SYN_IE(RenamedHsExpr) )
+import TcHsSyn ( TcIdOcc(..), SYN_IE(TcExpr), SYN_IE(TcIdBndr),
mkHsTyApp, mkHsDictApp, tcIdTyVars )
-import TcMonad hiding ( rnMtoTcM )
+import TcMonad
import TcEnv ( tcLookupGlobalValueByKey, tcLookupTyConByKey )
-import TcType ( TcType(..), TcRhoType(..), TcMaybe, TcTyVarSet(..),
+import TcType ( SYN_IE(TcType), SYN_IE(TcRhoType), TcMaybe, SYN_IE(TcTyVarSet),
tcInstType, zonkTcType )
import Bag ( emptyBag, unitBag, unionBags, unionManyBags, listToBag, consBag )
-import Class ( isCcallishClass, isNoDictClass, classInstEnv,
- Class(..), GenClass, ClassInstEnv(..)
+import Class ( classInstEnv,
+ SYN_IE(Class), GenClass, SYN_IE(ClassInstEnv), SYN_IE(ClassOp)
)
-import ErrUtils ( addErrLoc, Error(..) )
+import ErrUtils ( addErrLoc, SYN_IE(Error) )
import Id ( GenId, idType, mkInstId )
+import PrelInfo ( isCcallishClass, isNoDictClass )
import MatchEnv ( lookupMEnv, insertMEnv )
-import Name ( mkLocalName, getLocalName, Name )
+import Name ( OccName(..), Name, mkLocalName, mkSysLocalName, occNameString )
import Outputable
-import PprType ( GenClass, TyCon, GenType, GenTyVar )
+import PprType ( GenClass, TyCon, GenType, GenTyVar, pprParendGenType )
import PprStyle ( PprStyle(..) )
import Pretty
-import RnHsSyn ( RnName{-instance NamedThing-} )
-import SpecEnv ( SpecEnv(..) )
-import SrcLoc ( SrcLoc, mkUnknownSrcLoc )
+import SpecEnv ( SpecEnv )
+import SrcLoc ( SrcLoc, noSrcLoc )
import Type ( GenType, eqSimpleTy, instantiateTy,
isTyVarTy, mkDictTy, splitForAllTy, splitSigmaTy,
splitRhoTy, matchTy, tyVarsOfType, tyVarsOfTypes,
-> NF_TcM s (LIE s, [TcIdOcc s])
newDicts orig theta
= tcGetSrcLoc `thenNF_Tc` \ loc ->
+ newDictsAtLoc orig loc theta `thenNF_Tc` \ (dicts, ids) ->
+ returnNF_Tc (listToBag dicts, ids)
+{-
tcGetUniques (length theta) `thenNF_Tc` \ new_uniqs ->
let
mk_dict u (clas, ty) = Dict u clas ty orig loc
dicts = zipWithEqual "newDicts" mk_dict new_uniqs theta
in
returnNF_Tc (listToBag dicts, map instToId dicts)
-
-newDictsAtLoc orig loc theta -- Local function, similar to newDicts,
- -- but with slightly different interface
- = tcGetUniques (length theta) `thenNF_Tc` \ new_uniqs ->
- let
- mk_dict u (clas, ty) = Dict u clas ty orig loc
- dicts = zipWithEqual "newDictsAtLoc" mk_dict new_uniqs theta
- in
- returnNF_Tc (dicts, map instToId dicts)
+-}
+
+-- Local function, similar to newDicts,
+-- but with slightly different interface
+newDictsAtLoc :: InstOrigin s
+ -> SrcLoc
+ -> [(Class, TcType s)]
+ -> NF_TcM s ([Inst s], [TcIdOcc s])
+newDictsAtLoc orig loc theta =
+ tcGetUniques (length theta) `thenNF_Tc` \ new_uniqs ->
+ let
+ mk_dict u (clas, ty) = Dict u clas ty orig loc
+ dicts = zipWithEqual "newDictsAtLoc" mk_dict new_uniqs theta
+ in
+ returnNF_Tc (dicts, map instToId dicts)
newMethod :: InstOrigin s
-> TcIdOcc s
\begin{code}
instToId :: Inst s -> TcIdOcc s
instToId (Dict u clas ty orig loc)
- = TcId (mkInstId u (mkDictTy clas ty) (mkLocalName u str False{-emph name-} loc))
+ = TcId (mkInstId u (mkDictTy clas ty) (mkLocalName u str loc))
where
- str = SLIT("d.") _APPEND_ (getLocalName clas)
+ str = VarOcc (SLIT("d.") _APPEND_ (occNameString (getOccName clas)))
+
instToId (Method u id tys rho_ty orig loc)
- = TcId (mkInstId u tau_ty (mkLocalName u str False{-emph name-} loc))
+ = TcId (mkInstId u tau_ty (mkLocalName u str loc))
where
(_, tau_ty) = splitRhoTy rho_ty -- NB The method Id has just the tau type
- str = SLIT("m.") _APPEND_ (getLocalName id)
+ str = VarOcc (SLIT("m.") _APPEND_ (occNameString (getOccName id)))
instToId (LitInst u list ty orig loc)
- = TcId (mkInstId u ty (mkLocalName u SLIT("lit") True{-emph uniq-} loc))
+ = TcId (mkInstId u ty (mkSysLocalName u SLIT("lit") loc))
\end{code}
\begin{code}
4 (ppCat [case lit of
OverloadedIntegral i -> ppInteger i
OverloadedFractional f -> ppRational f,
- ppStr "at",
+ ppPStr SLIT("at"),
ppr sty ty,
show_uniq sty u])
ppr_inst sty hdr ppr_orig (Dict u clas ty orig loc)
= ppHang (ppr_orig orig loc)
- 4 (ppCat [ppr sty clas, ppr sty ty, show_uniq sty u])
+ 4 (ppCat [ppr sty clas, pprParendGenType sty ty, show_uniq sty u])
ppr_inst sty hdr ppr_orig (Method u id tys rho orig loc)
= ppHang (ppr_orig orig loc)
- 4 (ppCat [ppr sty id, ppStr "at", interppSP sty tys, show_uniq sty u])
+ 4 (ppCat [ppr sty id, ppPStr SLIT("at"), interppSP sty tys, show_uniq sty u])
show_uniq PprDebug u = ppr PprDebug u
show_uniq sty u = ppNil
(_, theta, _) = splitSigmaTy (idType dfun)
noSimpleInst clas ty sty
- = ppSep [ppStr "No instance for class", ppQuote (ppr sty clas),
- ppStr "at type", ppQuote (ppr sty ty)]
+ = ppSep [ppPStr SLIT("No instance for class"), ppQuote (ppr sty clas),
+ ppPStr SLIT("at type"), ppQuote (ppr sty ty)]
\end{code}
ppBesides [ppPStr SLIT("at a use of an overloaded constructor: `"),
ppr sty id, ppChar '\'']
InstanceDeclOrigin ->
- ppStr "in an instance declaration"
+ ppPStr SLIT("in an instance declaration")
LiteralOrigin lit ->
- ppCat [ppStr "at an overloaded literal:", ppr sty lit]
+ ppCat [ppPStr SLIT("at an overloaded literal:"), ppr sty lit]
ArithSeqOrigin seq ->
- ppCat [ppStr "at an arithmetic sequence:", ppr sty seq]
+ ppCat [ppPStr SLIT("at an arithmetic sequence:"), ppr sty seq]
SignatureOrigin ->
- ppStr "in a type signature"
+ ppPStr SLIT("in a type signature")
DoOrigin ->
- ppStr "in a do statement"
+ ppPStr SLIT("in a do statement")
ClassDeclOrigin ->
- ppStr "in a class declaration"
+ ppPStr SLIT("in a class declaration")
InstanceSpecOrigin _ clas ty ->
ppBesides [ppStr "in a SPECIALIZE instance pragma; class \"",
ppr sty clas, ppStr "\" type: ", ppr sty ty]
ValSpecOrigin name ->
- ppBesides [ppStr "in a SPECIALIZE user-pragma for `",
- ppr sty name, ppStr "'"]
+ ppBesides [ppPStr SLIT("in a SPECIALIZE user-pragma for `"),
+ ppr sty name, ppChar '\'']
CCallOrigin clabel Nothing{-ccall result-} ->
- ppBesides [ppStr "in the result of the _ccall_ to `",
- ppStr clabel, ppStr "'"]
+ ppBesides [ppPStr SLIT("in the result of the _ccall_ to `"),
+ ppStr clabel, ppChar '\'']
CCallOrigin clabel (Just arg_expr) ->
- ppBesides [ppStr "in an argument in the _ccall_ to `",
+ ppBesides [ppPStr SLIT("in an argument in the _ccall_ to `"),
ppStr clabel, ppStr "', namely: ", ppr sty arg_expr]
LitLitOrigin s ->
- ppBesides [ppStr "in this ``literal-literal'': ", ppStr s]
+ ppBesides [ppPStr SLIT("in this ``literal-literal'': "), ppStr s]
UnknownOrigin ->
- ppStr "in... oops -- I don't know where the overloading came from!"
+ ppPStr SLIT("in... oops -- I don't know where the overloading came from!")
\end{code}