2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
4 \section[Inst]{The @Inst@ type: dictionaries or method instances}
7 #include "HsVersions.h"
10 Inst(..), -- Visible only to TcSimplify
12 InstOrigin(..), OverloadedLit(..),
13 SYN_IE(LIE), emptyLIE, unitLIE, plusLIE, consLIE, zonkLIE, plusLIEs,
15 SYN_IE(InstanceMapper),
17 newDicts, newDictsAtLoc, newMethod, newMethodWithGivenTy, newOverloadedLit,
19 instType, tyVarsOfInst, lookupInst, lookupSimpleInst,
26 instBindingRequired, instCanBeGeneralised,
32 IMPORT_1_3(Ratio(Rational))
34 import HsSyn ( HsLit(..), HsExpr(..), HsBinds,
35 InPat, OutPat, Stmt, Qualifier, Match,
36 ArithSeqInfo, HsType, Fake )
37 import RnHsSyn ( SYN_IE(RenamedArithSeqInfo), SYN_IE(RenamedHsExpr) )
38 import TcHsSyn ( TcIdOcc(..), SYN_IE(TcExpr), SYN_IE(TcIdBndr),
39 mkHsTyApp, mkHsDictApp, tcIdTyVars )
42 import TcEnv ( tcLookupGlobalValueByKey, tcLookupTyConByKey )
43 import TcType ( SYN_IE(TcType), SYN_IE(TcRhoType), TcMaybe, SYN_IE(TcTyVarSet),
44 tcInstType, zonkTcType )
46 import Bag ( emptyBag, unitBag, unionBags, unionManyBags, listToBag, consBag )
47 import Class ( classInstEnv,
48 SYN_IE(Class), GenClass, SYN_IE(ClassInstEnv), SYN_IE(ClassOp)
50 import ErrUtils ( addErrLoc, SYN_IE(Error) )
51 import Id ( GenId, idType, mkInstId )
52 import PrelInfo ( isCcallishClass, isNoDictClass )
53 import MatchEnv ( lookupMEnv, insertMEnv )
54 import Name ( OccName(..), Name, mkLocalName, mkSysLocalName, occNameString )
56 import PprType ( GenClass, TyCon, GenType, GenTyVar, pprParendGenType )
57 import PprStyle ( PprStyle(..) )
59 import SpecEnv ( SpecEnv )
60 import SrcLoc ( SrcLoc, noSrcLoc )
61 import Type ( GenType, eqSimpleTy, instantiateTy,
62 isTyVarTy, mkDictTy, splitForAllTy, splitSigmaTy,
63 splitRhoTy, matchTy, tyVarsOfType, tyVarsOfTypes,
66 import TyVar ( unionTyVarSets, GenTyVar )
67 import TysPrim ( intPrimTy )
68 import TysWiredIn ( intDataCon, integerTy )
69 import Unique ( showUnique, fromRationalClassOpKey, rationalTyConKey,
70 fromIntClassOpKey, fromIntegerClassOpKey, Unique
72 import Util ( panic, zipEqual, zipWithEqual, assoc, assertPanic, pprTrace{-ToDo:rm-} )
75 %************************************************************************
77 \subsection[Inst-collections]{LIE: a collection of Insts}
79 %************************************************************************
82 type LIE s = Bag (Inst s)
85 unitLIE inst = unitBag inst
86 plusLIE lie1 lie2 = lie1 `unionBags` lie2
87 consLIE inst lie = inst `consBag` lie
88 plusLIEs lies = unionManyBags lies
90 zonkLIE :: LIE s -> NF_TcM s (LIE s)
91 zonkLIE lie = mapBagNF_Tc zonkInst lie
94 %************************************************************************
96 \subsection[Inst-types]{@Inst@ types}
98 %************************************************************************
100 An @Inst@ is either a dictionary, an instance of an overloaded
101 literal, or an instance of an overloaded value. We call the latter a
102 ``method'' even though it may not correspond to a class operation.
103 For example, we might have an instance of the @double@ function at
104 type Int, represented by
106 Method 34 doubleId [Int] origin
112 Class -- The type of the dict is (c t), where
113 (TcType s) -- c is the class and t the type;
120 (TcIdOcc s) -- The overloaded function
121 -- This function will be a global, local, or ClassOpId;
122 -- inside instance decls (only) it can also be an InstId!
123 -- The id needn't be completely polymorphic.
124 -- You'll probably find its name (for documentation purposes)
125 -- inside the InstOrigin
127 [TcType s] -- The types to which its polymorphic tyvars
128 -- should be instantiated.
129 -- These types must saturate the Id's foralls.
131 (TcRhoType s) -- Cached: (type-of-id applied to inst_tys)
132 -- If this type is (theta => tau) then the type of the Method
133 -- is tau, and the method can be built by saying
135 -- where dicts are constructed from theta
143 (TcType s) -- The type at which the literal is used
144 (InstOrigin s) -- Always a literal; but more convenient to carry this around
148 = OverloadedIntegral Integer -- The number
149 | OverloadedFractional Rational -- The number
151 getInstOrigin (Dict u clas ty origin loc) = origin
152 getInstOrigin (Method u clas ty rho origin loc) = origin
153 getInstOrigin (LitInst u lit ty origin loc) = origin
160 newDicts :: InstOrigin s
161 -> [(Class, TcType s)]
162 -> NF_TcM s (LIE s, [TcIdOcc s])
164 = tcGetSrcLoc `thenNF_Tc` \ loc ->
165 newDictsAtLoc orig loc theta `thenNF_Tc` \ (dicts, ids) ->
166 returnNF_Tc (listToBag dicts, ids)
168 tcGetUniques (length theta) `thenNF_Tc` \ new_uniqs ->
170 mk_dict u (clas, ty) = Dict u clas ty orig loc
171 dicts = zipWithEqual "newDicts" mk_dict new_uniqs theta
173 returnNF_Tc (listToBag dicts, map instToId dicts)
176 -- Local function, similar to newDicts,
177 -- but with slightly different interface
178 newDictsAtLoc :: InstOrigin s
180 -> [(Class, TcType s)]
181 -> NF_TcM s ([Inst s], [TcIdOcc s])
182 newDictsAtLoc orig loc theta =
183 tcGetUniques (length theta) `thenNF_Tc` \ new_uniqs ->
185 mk_dict u (clas, ty) = Dict u clas ty orig loc
186 dicts = zipWithEqual "newDictsAtLoc" mk_dict new_uniqs theta
188 returnNF_Tc (dicts, map instToId dicts)
190 newMethod :: InstOrigin s
193 -> NF_TcM s (LIE s, TcIdOcc s)
194 newMethod orig id tys
195 = -- Get the Id type and instantiate it at the specified types
197 RealId id -> let (tyvars, rho) = splitForAllTy (idType id)
199 (if length tyvars /= length tys then pprTrace "newMethod" (ppr PprDebug (idType id)) else \x->x) $
200 tcInstType (zip{-Equal "newMethod"-} tyvars tys) rho
201 TcId id -> let (tyvars, rho) = splitForAllTy (idType id)
202 in returnNF_Tc (instantiateTy (zipEqual "newMethod(2)" tyvars tys) rho)
203 ) `thenNF_Tc` \ rho_ty ->
204 -- Our friend does the rest
205 newMethodWithGivenTy orig id tys rho_ty
208 newMethodWithGivenTy orig id tys rho_ty
209 = tcGetSrcLoc `thenNF_Tc` \ loc ->
210 tcGetUnique `thenNF_Tc` \ new_uniq ->
212 meth_inst = Method new_uniq id tys rho_ty orig loc
214 returnNF_Tc (unitLIE meth_inst, instToId meth_inst)
216 newMethodAtLoc :: InstOrigin s -> SrcLoc -> Id -> [TcType s] -> NF_TcM s (Inst s, TcIdOcc s)
217 newMethodAtLoc orig loc real_id tys -- Local function, similar to newMethod but with
218 -- slightly different interface
219 = -- Get the Id type and instantiate it at the specified types
221 (tyvars,rho) = splitForAllTy (idType real_id)
223 tcInstType (zipEqual "newMethodAtLoc" tyvars tys) rho `thenNF_Tc` \ rho_ty ->
224 tcGetUnique `thenNF_Tc` \ new_uniq ->
226 meth_inst = Method new_uniq (RealId real_id) tys rho_ty orig loc
228 returnNF_Tc (meth_inst, instToId meth_inst)
230 newOverloadedLit :: InstOrigin s
233 -> NF_TcM s (LIE s, TcIdOcc s)
234 newOverloadedLit orig lit ty
235 = tcGetSrcLoc `thenNF_Tc` \ loc ->
236 tcGetUnique `thenNF_Tc` \ new_uniq ->
238 lit_inst = LitInst new_uniq lit ty orig loc
240 returnNF_Tc (unitLIE lit_inst, instToId lit_inst)
245 instToId :: Inst s -> TcIdOcc s
246 instToId (Dict u clas ty orig loc)
247 = TcId (mkInstId u (mkDictTy clas ty) (mkLocalName u str loc))
249 str = VarOcc (SLIT("d.") _APPEND_ (occNameString (getOccName clas)))
251 instToId (Method u id tys rho_ty orig loc)
252 = TcId (mkInstId u tau_ty (mkLocalName u str loc))
254 (_, tau_ty) = splitRhoTy rho_ty -- NB The method Id has just the tau type
255 str = VarOcc (SLIT("m.") _APPEND_ (occNameString (getOccName id)))
257 instToId (LitInst u list ty orig loc)
258 = TcId (mkInstId u ty (mkSysLocalName u SLIT("lit") loc))
262 instType :: Inst s -> TcType s
263 instType (Dict _ clas ty _ _) = mkDictTy clas ty
264 instType (LitInst _ _ ty _ _) = ty
265 instType (Method _ id tys ty _ _) = ty
271 Zonking makes sure that the instance types are fully zonked,
272 but doesn't do the same for the Id in a Method. There's no
273 need, and it's a lot of extra work.
276 zonkInst :: Inst s -> NF_TcM s (Inst s)
277 zonkInst (Dict u clas ty orig loc)
278 = zonkTcType ty `thenNF_Tc` \ new_ty ->
279 returnNF_Tc (Dict u clas new_ty orig loc)
281 zonkInst (Method u id tys rho orig loc) -- Doesn't zonk the id!
282 = mapNF_Tc zonkTcType tys `thenNF_Tc` \ new_tys ->
283 zonkTcType rho `thenNF_Tc` \ new_rho ->
284 returnNF_Tc (Method u id new_tys new_rho orig loc)
286 zonkInst (LitInst u lit ty orig loc)
287 = zonkTcType ty `thenNF_Tc` \ new_ty ->
288 returnNF_Tc (LitInst u lit new_ty orig loc)
293 tyVarsOfInst :: Inst s -> TcTyVarSet s
294 tyVarsOfInst (Dict _ _ ty _ _) = tyVarsOfType ty
295 tyVarsOfInst (Method _ id tys rho _ _) = tyVarsOfTypes tys `unionTyVarSets` tcIdTyVars id
296 -- The id might not be a RealId; in the case of
297 -- locally-overloaded class methods, for example
298 tyVarsOfInst (LitInst _ _ ty _ _) = tyVarsOfType ty
301 @matchesInst@ checks when two @Inst@s are instances of the same
302 thing at the same type, even if their uniques differ.
305 matchesInst :: Inst s -> Inst s -> Bool
307 matchesInst (Dict _ clas1 ty1 _ _) (Dict _ clas2 ty2 _ _)
308 = clas1 == clas2 && ty1 `eqSimpleTy` ty2
310 matchesInst (Method _ id1 tys1 _ _ _) (Method _ id2 tys2 _ _ _)
312 && and (zipWith eqSimpleTy tys1 tys2)
313 && length tys1 == length tys2
315 matchesInst (LitInst _ lit1 ty1 _ _) (LitInst _ lit2 ty2 _ _)
316 = lit1 `eq` lit2 && ty1 `eqSimpleTy` ty2
318 (OverloadedIntegral i1) `eq` (OverloadedIntegral i2) = i1 == i2
319 (OverloadedFractional f1) `eq` (OverloadedFractional f2) = f1 == f2
322 matchesInst other1 other2 = False
329 isDict :: Inst s -> Bool
330 isDict (Dict _ _ _ _ _) = True
333 isTyVarDict :: Inst s -> Bool
334 isTyVarDict (Dict _ _ ty _ _) = isTyVarTy ty
335 isTyVarDict other = False
338 Two predicates which deal with the case where class constraints don't
339 necessarily result in bindings. The first tells whether an @Inst@
340 must be witnessed by an actual binding; the second tells whether an
341 @Inst@ can be generalised over.
344 instBindingRequired :: Inst s -> Bool
345 instBindingRequired (Dict _ clas _ _ _) = not (isNoDictClass clas)
346 instBindingRequired other = True
348 instCanBeGeneralised :: Inst s -> Bool
349 instCanBeGeneralised (Dict _ clas _ _ _) = not (isCcallishClass clas)
350 instCanBeGeneralised other = True
356 ToDo: improve these pretty-printing things. The ``origin'' is really only
357 relevant in error messages.
360 instance Outputable (Inst s) where
361 ppr sty inst = ppr_inst sty ppNil (\ o l -> ppNil) inst
363 pprInst sty hdr inst = ppr_inst sty hdr (\ o l -> pprOrigin hdr o l sty) inst
365 ppr_inst sty hdr ppr_orig (LitInst u lit ty orig loc)
366 = ppHang (ppr_orig orig loc)
367 4 (ppCat [case lit of
368 OverloadedIntegral i -> ppInteger i
369 OverloadedFractional f -> ppRational f,
374 ppr_inst sty hdr ppr_orig (Dict u clas ty orig loc)
375 = ppHang (ppr_orig orig loc)
376 4 (ppCat [ppr sty clas, pprParendGenType sty ty, show_uniq sty u])
378 ppr_inst sty hdr ppr_orig (Method u id tys rho orig loc)
379 = ppHang (ppr_orig orig loc)
380 4 (ppCat [ppr sty id, ppStr "at", interppSP sty tys, show_uniq sty u])
382 show_uniq PprDebug u = ppr PprDebug u
383 show_uniq sty u = ppNil
386 Printing in error messages
389 noInstanceErr inst sty = ppHang (ppPStr SLIT("No instance for:")) 4 (ppr sty inst)
392 %************************************************************************
394 \subsection[InstEnv-types]{Type declarations}
396 %************************************************************************
399 type InstanceMapper = Class -> (ClassInstEnv, ClassOp -> SpecEnv)
402 A @ClassInstEnv@ lives inside a class, and identifies all the instances
403 of that class. The @Id@ inside a ClassInstEnv mapping is the dfun for
406 There is an important consistency constraint between the @MatchEnv@s
407 in and the dfun @Id@s inside them: the free type variables of the
408 @Type@ key in the @MatchEnv@ must be a subset of the universally-quantified
409 type variables of the dfun. Thus, the @ClassInstEnv@ for @Eq@ might
410 contain the following entry:
412 [a] ===> dfun_Eq_List :: forall a. Eq a => Eq [a]
414 The "a" in the pattern must be one of the forall'd variables in
420 (TcIdOcc s, TcExpr s)) -- The new binding
424 lookupInst dict@(Dict _ clas ty orig loc)
425 = case lookupMEnv matchTy (get_inst_env clas orig) ty of
426 Nothing -> tcAddSrcLoc loc $
427 tcAddErrCtxt (pprOrigin ""{-hdr-} orig loc) $
428 failTc (noInstanceErr dict)
432 (tyvars, rho) = splitForAllTy (idType dfun_id)
433 ty_args = map (assoc "lookupInst" tenv) tyvars
434 -- tenv should bind all the tyvars
436 tcInstType tenv rho `thenNF_Tc` \ dfun_rho ->
438 (theta, tau) = splitRhoTy dfun_rho
440 newDictsAtLoc orig loc theta `thenNF_Tc` \ (dicts, dict_ids) ->
442 rhs = mkHsDictApp (mkHsTyApp (HsVar (RealId dfun_id)) ty_args) dict_ids
444 returnTc (dicts, (instToId dict, rhs))
449 lookupInst inst@(Method _ id tys rho orig loc)
450 = newDictsAtLoc orig loc theta `thenNF_Tc` \ (dicts, dict_ids) ->
451 returnTc (dicts, (instToId inst, mkHsDictApp (mkHsTyApp (HsVar id) tys) dict_ids))
453 (theta,_) = splitRhoTy rho
457 lookupInst inst@(LitInst u (OverloadedIntegral i) ty orig loc)
458 | i >= toInteger minInt && i <= toInteger maxInt
459 = -- It's overloaded but small enough to fit into an Int
460 tcLookupGlobalValueByKey fromIntClassOpKey `thenNF_Tc` \ from_int ->
461 newMethodAtLoc orig loc from_int [ty] `thenNF_Tc` \ (method_inst, method_id) ->
462 returnTc ([method_inst], (instToId inst, HsApp (HsVar method_id) int_lit))
465 = -- Alas, it is overloaded and a big literal!
466 tcLookupGlobalValueByKey fromIntegerClassOpKey `thenNF_Tc` \ from_integer ->
467 newMethodAtLoc orig loc from_integer [ty] `thenNF_Tc` \ (method_inst, method_id) ->
468 returnTc ([method_inst], (instToId inst, HsApp (HsVar method_id) (HsLitOut (HsInt i) integerTy)))
470 intprim_lit = HsLitOut (HsIntPrim i) intPrimTy
471 int_lit = HsApp (HsVar (RealId intDataCon)) intprim_lit
473 lookupInst inst@(LitInst u (OverloadedFractional f) ty orig loc)
474 = tcLookupGlobalValueByKey fromRationalClassOpKey `thenNF_Tc` \ from_rational ->
476 -- The type Rational isn't wired in so we have to conjure it up
477 tcLookupTyConByKey rationalTyConKey `thenNF_Tc` \ rational_tycon ->
479 rational_ty = mkSynTy rational_tycon []
480 rational_lit = HsLitOut (HsFrac f) rational_ty
482 newMethodAtLoc orig loc from_rational [ty] `thenNF_Tc` \ (method_inst, method_id) ->
483 returnTc ([method_inst], (instToId inst, HsApp (HsVar method_id) rational_lit))
486 There is a second, simpler interface, when you want an instance of a
487 class at a given nullary type constructor. It just returns the
488 appropriate dictionary if it exists. It is used only when resolving
489 ambiguous dictionaries.
492 lookupSimpleInst :: ClassInstEnv
494 -> Type -- Look up (c,t)
495 -> TcM s [(Class,Type)] -- Here are the needed (c,t)s
497 lookupSimpleInst class_inst_env clas ty
498 = case (lookupMEnv matchTy class_inst_env ty) of
499 Nothing -> failTc (noSimpleInst clas ty)
500 Just (dfun,tenv) -> returnTc [(c,instantiateTy tenv t) | (c,t) <- theta]
502 (_, theta, _) = splitSigmaTy (idType dfun)
504 noSimpleInst clas ty sty
505 = ppSep [ppStr "No instance for class", ppQuote (ppr sty clas),
506 ppStr "at type", ppQuote (ppr sty ty)]
510 @mkInstSpecEnv@ is used to construct the @SpecEnv@ for a dfun.
511 It does it by filtering the class's @InstEnv@. All pretty shady stuff.
514 mkInstSpecEnv clas inst_ty inst_tvs inst_theta = panic "mkInstSpecEnv"
518 mkInstSpecEnv :: Class -- class
519 -> Type -- instance type
520 -> [TyVarTemplate] -- instance tyvars
521 -> ThetaType -- superclasses dicts
522 -> SpecEnv -- specenv for dfun of instance
524 mkInstSpecEnv clas inst_ty inst_tvs inst_theta
525 = mkSpecEnv (catMaybes (map maybe_spec_info matches))
527 matches = matchMEnv matchTy (classInstEnv clas) inst_ty
529 maybe_spec_info (_, match_info, MkInstTemplate dfun _ [])
530 = Just (SpecInfo (map (assocMaybe match_info) inst_tvs) (length inst_theta) dfun)
531 maybe_spec_info (_, match_info, _)
538 :: ClassInstEnv -- Incoming envt
539 -> Type -- The instance type: inst_ty
540 -> Id -- Dict fun id to apply. Free tyvars of inst_ty must
541 -- be the same as the forall'd tyvars of the dfun id.
543 ClassInstEnv -- Success
544 (Type, Id) -- Offending overlap
546 addClassInst inst_env inst_ty dfun_id = insertMEnv matchTy inst_env inst_ty dfun_id
551 %************************************************************************
553 \subsection[Inst-origin]{The @InstOrigin@ type}
555 %************************************************************************
557 The @InstOrigin@ type gives information about where a dictionary came from.
558 This is important for decent error message reporting because dictionaries
559 don't appear in the original source code. Doubtless this type will evolve...
563 = OccurrenceOf (TcIdOcc s) -- Occurrence of an overloaded identifier
564 | OccurrenceOfCon Id -- Occurrence of a data constructor
568 | DataDeclOrigin -- Typechecking a data declaration
570 | InstanceDeclOrigin -- Typechecking an instance decl
572 | LiteralOrigin HsLit -- Occurrence of a literal
574 | ArithSeqOrigin RenamedArithSeqInfo -- [x..], [x..y] etc
576 | SignatureOrigin -- A dict created from a type signature
578 | DoOrigin -- The monad for a do expression
580 | ClassDeclOrigin -- Manufactured during a class decl
583 -- | DerivingOrigin InstanceMapper
587 -- During "deriving" operations we have an ever changing
588 -- mapping of classes to instances, so we record it inside the
589 -- origin information. This is a bit of a hack, but it works
590 -- fine. (Simon is to blame [WDP].)
592 | InstanceSpecOrigin InstanceMapper
593 Class -- in a SPECIALIZE instance pragma
596 -- When specialising instances the instance info attached to
597 -- each class is not yet ready, so we record it inside the
598 -- origin information. This is a bit of a hack, but it works
599 -- fine. (Patrick is to blame [WDP].)
601 -- | DefaultDeclOrigin -- Related to a `default' declaration
603 | ValSpecOrigin Name -- in a SPECIALIZE pragma for a value
605 -- Argument or result of a ccall
606 -- Dictionaries with this origin aren't actually mentioned in the
607 -- translated term, and so need not be bound. Nor should they
608 -- be abstracted over.
610 | CCallOrigin String -- CCall label
611 (Maybe RenamedHsExpr) -- Nothing if it's the result
612 -- Just arg, for an argument
614 | LitLitOrigin String -- the litlit
616 | UnknownOrigin -- Help! I give up...
620 -- During deriving and instance specialisation operations
621 -- we can't get the instances of the class from inside the
622 -- class, because the latter ain't ready yet. Instead we
623 -- find a mapping from classes to envts inside the dict origin.
625 get_inst_env :: Class -> InstOrigin s -> ClassInstEnv
626 -- get_inst_env clas (DerivingOrigin inst_mapper _ _)
627 -- = fst (inst_mapper clas)
628 get_inst_env clas (InstanceSpecOrigin inst_mapper _ _)
629 = fst (inst_mapper clas)
630 get_inst_env clas other_orig = classInstEnv clas
633 pprOrigin :: String -> InstOrigin s -> SrcLoc -> Error
635 pprOrigin hdr orig locn
636 = addErrLoc locn hdr $ \ sty ->
639 ppBesides [ppPStr SLIT("at a use of an overloaded identifier: `"),
640 ppr sty id, ppChar '\'']
641 OccurrenceOfCon id ->
642 ppBesides [ppPStr SLIT("at a use of an overloaded constructor: `"),
643 ppr sty id, ppChar '\'']
644 InstanceDeclOrigin ->
645 ppStr "in an instance declaration"
647 ppCat [ppStr "at an overloaded literal:", ppr sty lit]
648 ArithSeqOrigin seq ->
649 ppCat [ppStr "at an arithmetic sequence:", ppr sty seq]
651 ppStr "in a type signature"
653 ppStr "in a do statement"
655 ppStr "in a class declaration"
656 InstanceSpecOrigin _ clas ty ->
657 ppBesides [ppStr "in a SPECIALIZE instance pragma; class \"",
658 ppr sty clas, ppStr "\" type: ", ppr sty ty]
659 ValSpecOrigin name ->
660 ppBesides [ppStr "in a SPECIALIZE user-pragma for `",
661 ppr sty name, ppStr "'"]
662 CCallOrigin clabel Nothing{-ccall result-} ->
663 ppBesides [ppStr "in the result of the _ccall_ to `",
664 ppStr clabel, ppStr "'"]
665 CCallOrigin clabel (Just arg_expr) ->
666 ppBesides [ppStr "in an argument in the _ccall_ to `",
667 ppStr clabel, ppStr "', namely: ", ppr sty arg_expr]
669 ppBesides [ppStr "in this ``literal-literal'': ", ppStr s]
671 ppStr "in... oops -- I don't know where the overloading came from!"