-import Util ( panic, zipEqual, zipWithEqual, assoc, assertPanic, pprTrace{-ToDo:rm-} )
-#if __GLASGOW_HASKELL__ >= 202
-import Maybes
-#endif
-\end{code}
-
-%************************************************************************
-%* *
-\subsection[Inst-collections]{LIE: a collection of Insts}
-%* *
-%************************************************************************
-
-\begin{code}
-type LIE s = Bag (Inst s)
-
-emptyLIE = emptyBag
-unitLIE inst = unitBag inst
-plusLIE lie1 lie2 = lie1 `unionBags` lie2
-consLIE inst lie = inst `consBag` lie
-plusLIEs lies = unionManyBags lies
-
-zonkLIE :: LIE s -> NF_TcM s (LIE s)
-zonkLIE lie = mapBagNF_Tc zonkInst lie
-
-pprLIE :: PprStyle -> LIE s -> Doc
-pprLIE sty lie = pprQuote sty $ \ sty ->
- braces (hsep (punctuate comma (map (pprInst sty) (bagToList lie))))
-
-
-pprLIEInFull sty insts
- = vcat (map go (bagToList insts))
- where
- go inst = ppr sty inst <+> pprOrigin sty inst
-\end{code}
-
-%************************************************************************
-%* *
-\subsection[Inst-types]{@Inst@ types}
-%* *
-%************************************************************************
-
-An @Inst@ is either a dictionary, an instance of an overloaded
-literal, or an instance of an overloaded value. We call the latter a
-``method'' even though it may not correspond to a class operation.
-For example, we might have an instance of the @double@ function at
-type Int, represented by
-
- Method 34 doubleId [Int] origin
-
-\begin{code}
-data Inst s
- = Dict
- Unique
- Class -- The type of the dict is (c t), where
- (TcType s) -- c is the class and t the type;
- (InstOrigin s)
- SrcLoc
-
- | Method
- Unique
-
- (TcIdOcc s) -- The overloaded function
- -- This function will be a global, local, or ClassOpId;
- -- inside instance decls (only) it can also be an InstId!
- -- The id needn't be completely polymorphic.
- -- You'll probably find its name (for documentation purposes)
- -- inside the InstOrigin
-
- [TcType s] -- The types to which its polymorphic tyvars
- -- should be instantiated.
- -- These types must saturate the Id's foralls.
-
- (TcRhoType s) -- Cached: (type-of-id applied to inst_tys)
- -- If this type is (theta => tau) then the type of the Method
- -- is tau, and the method can be built by saying
- -- id inst_tys dicts
- -- where dicts are constructed from theta
-
- (InstOrigin s)
- SrcLoc
-
- | LitInst
- Unique
- OverloadedLit
- (TcType s) -- The type at which the literal is used
- (InstOrigin s) -- Always a literal; but more convenient to carry this around
- SrcLoc
-
-data OverloadedLit
- = OverloadedIntegral Integer -- The number
- | OverloadedFractional Rational -- The number
-
-getInstOrigin (Dict u clas ty origin loc) = origin
-getInstOrigin (Method u clas ty rho origin loc) = origin
-getInstOrigin (LitInst u lit ty origin loc) = origin
+import CoreFVs ( idFreeTyVars )
+import Class ( Class )
+import DataCon ( DataCon,dataConSig )
+import Id ( Id, idName, idType, mkUserLocal, mkSysLocal, mkLocalId, setIdUnique )
+import PrelInfo ( isStandardClass, isCcallishClass, isNoDictClass )
+import Name ( Name, mkMethodOcc, getOccName )
+import PprType ( pprPred, pprParendType )
+import Subst ( emptyInScopeSet, mkSubst, substTy, substTyWith, substTheta, mkTyVarSubst )
+import Literal ( inIntRange )
+import Var ( TyVar )
+import VarEnv ( TidyEnv, emptyTidyEnv, lookupSubstEnv, SubstResult(..) )
+import VarSet ( elemVarSet, emptyVarSet, unionVarSet )
+import TysWiredIn ( floatDataCon, doubleDataCon )
+import PrelNames( fromIntegerName, fromRationalName, rationalTyConName )
+import BasicTypes( IPName(..), mapIPName, ipNameName )
+import UniqSupply( uniqsFromSupply )
+import Outputable