import CmdLineOpts ( opt_NoMethodSharing )
import HsSyn ( HsLit(..), HsOverLit(..), HsExpr(..) )
-import RnHsSyn ( RenamedHsOverLit )
import TcHsSyn ( TcExpr, TcId,
mkHsTyApp, mkHsDictApp, mkHsConApp, zonkId
)
import TcMonad
-import TcEnv ( TcIdSet, tcGetInstEnv, tcLookupGlobalId )
+import TcEnv ( TcIdSet, tcGetInstEnv, tcLookupSyntaxId )
import InstEnv ( InstLookupResult(..), lookupInstEnv )
import TcType ( TcThetaType, TcClassContext,
TcType, TcTauType, TcTyVarSet,
)
import CoreFVs ( idFreeTyVars )
import Class ( Class )
-import Id ( Id, idType, mkUserLocal, mkSysLocal, mkVanillaId )
+import Id ( Id, idType, mkUserLocal, mkSysLocal, mkLocalId )
import PrelInfo ( isStandardClass, isCcallishClass, isNoDictClass )
import Name ( mkDictOcc, mkMethodOcc, getOccName, mkLocalName )
import NameSet ( NameSet )
doubleDataCon, isDoubleTy,
isIntegerTy
)
-import PrelNames( hasKey, fromIntName, fromIntegerClassOpKey )
+import PrelNames( fromIntegerName, fromRationalName )
import Util ( thenCmp, zipWithEqual, mapAccumL )
import Bag
import Outputable
| LitInst
Id
- RenamedHsOverLit -- The literal from the occurrence site
- TcType -- The type at which the literal is used
+ HsOverLit -- The literal from the occurrence site
+ TcType -- The type at which the literal is used
InstLoc
\end{code}
= tcGetUniques (length theta) `thenNF_Tc` \ new_uniqs ->
returnNF_Tc (zipWithEqual "newDictsAtLoc" mk_dict new_uniqs theta)
where
- mk_dict uniq pred = Dict (mkVanillaId (mk_dict_name uniq pred) (mkPredTy pred)) pred inst_loc
+ mk_dict uniq pred = Dict (mkLocalId (mk_dict_name uniq pred) (mkPredTy pred)) pred inst_loc
mk_dict_name uniq (Class cls tys) = mkLocalName uniq (mkDictOcc (getOccName cls)) loc
mk_dict_name uniq (IParam name ty) = name
newIPDict orig name ty
= tcGetInstLoc orig `thenNF_Tc` \ inst_loc ->
- returnNF_Tc (Dict (mkVanillaId name ty) (IParam name ty) inst_loc)
+ returnNF_Tc (Dict (mkLocalId name ty) (IParam name ty) inst_loc)
\end{code}
\begin{code}
newOverloadedLit :: InstOrigin
- -> RenamedHsOverLit
+ -> HsOverLit
-> TcType
-> NF_TcM (TcExpr, LIE)
-newOverloadedLit orig (HsIntegral i _) ty
+newOverloadedLit orig (HsIntegral i) ty
| isIntTy ty && inIntRange i -- Short cut for Int
= returnNF_Tc (int_lit, emptyLIE)
-- Literals
-lookupInst inst@(LitInst u (HsIntegral i from_integer_name) ty loc)
+lookupInst inst@(LitInst u (HsIntegral i) ty loc)
| isIntTy ty && in_int_range -- Short cut for Int
= returnNF_Tc (GenInst [] int_lit)
-- GenInst, not SimpleInst, because int_lit is actually a constructor application
| isIntegerTy ty -- Short cut for Integer
= returnNF_Tc (GenInst [] integer_lit)
- | in_int_range -- It's overloaded but small enough to fit into an Int
- && from_integer_name `hasKey` fromIntegerClassOpKey -- And it's the built-in prelude fromInteger
- -- (i.e. no funny business with user-defined
- -- packages of numeric classes)
- = -- So we can use the Prelude fromInt
- tcLookupGlobalId fromIntName `thenNF_Tc` \ from_int ->
- newMethodAtLoc loc from_int [ty] `thenNF_Tc` \ (method_inst, method_id) ->
- returnNF_Tc (GenInst [method_inst] (HsApp (HsVar method_id) int_lit))
-
| otherwise -- Alas, it is overloaded and a big literal!
- = tcLookupGlobalId from_integer_name `thenNF_Tc` \ from_integer ->
+ = tcLookupSyntaxId fromIntegerName `thenNF_Tc` \ from_integer ->
newMethodAtLoc loc from_integer [ty] `thenNF_Tc` \ (method_inst, method_id) ->
returnNF_Tc (GenInst [method_inst] (HsApp (HsVar method_id) integer_lit))
where
-- *definitely* a float or a double, generate the real thing here.
-- This is essential (see nofib/spectral/nucleic).
-lookupInst inst@(LitInst u (HsFractional f from_rat_name) ty loc)
+lookupInst inst@(LitInst u (HsFractional f) ty loc)
| isFloatTy ty = returnNF_Tc (GenInst [] float_lit)
| isDoubleTy ty = returnNF_Tc (GenInst [] double_lit)
| otherwise
- = tcLookupGlobalId from_rat_name `thenNF_Tc` \ from_rational ->
+ = tcLookupSyntaxId fromRationalName `thenNF_Tc` \ from_rational ->
newMethodAtLoc loc from_rational [ty] `thenNF_Tc` \ (method_inst, method_id) ->
let
rational_ty = funArgTy (idType method_id)