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,
16 SYN_IE(InstanceMapper),
18 newDicts, newDictsAtLoc, newMethod, newMethodWithGivenTy, newOverloadedLit,
20 instType, tyVarsOfInst, lookupInst, lookupSimpleInst,
27 instBindingRequired, instCanBeGeneralised,
33 IMPORT_1_3(Ratio(Rational))
35 import HsSyn ( HsLit(..), HsExpr(..), HsBinds, Fixity, MonoBinds(..),
36 InPat, OutPat, Stmt, DoOrListComp, Match, GRHSsAndBinds,
37 ArithSeqInfo, HsType, Fake )
38 import RnHsSyn ( SYN_IE(RenamedArithSeqInfo), SYN_IE(RenamedHsExpr) )
39 import TcHsSyn ( TcIdOcc(..), SYN_IE(TcExpr), SYN_IE(TcIdBndr),
40 SYN_IE(TcDictBinds), SYN_IE(TcMonoBinds),
41 mkHsTyApp, mkHsDictApp, tcIdTyVars )
44 import TcEnv ( tcLookupGlobalValueByKey, tcLookupTyConByKey )
45 import TcType ( SYN_IE(TcType), SYN_IE(TcRhoType), TcMaybe, SYN_IE(TcTyVarSet),
46 tcInstType, zonkTcType, tcSplitForAllTy, tcSplitRhoTy )
48 import Bag ( emptyBag, unitBag, unionBags, unionManyBags, bagToList,
49 listToBag, consBag, Bag )
50 import Class ( classInstEnv,
51 SYN_IE(Class), GenClass, SYN_IE(ClassInstEnv)
53 import ErrUtils ( addErrLoc, SYN_IE(Error) )
54 import Id ( GenId, idType, mkInstId, SYN_IE(Id) )
55 import PrelInfo ( isCcallishClass, isNoDictClass )
56 import MatchEnv ( lookupMEnv, insertMEnv )
57 import Name ( OccName(..), Name, mkLocalName,
58 mkSysLocalName, occNameString, getOccName )
60 import PprType ( GenClass, TyCon, GenType, GenTyVar, pprParendGenType )
62 import SpecEnv ( SpecEnv )
63 import SrcLoc ( SrcLoc, noSrcLoc )
64 import Type ( GenType, eqSimpleTy, instantiateTy,
65 isTyVarTy, mkDictTy, splitForAllTy, splitSigmaTy,
66 splitRhoTy, matchTy, tyVarsOfType, tyVarsOfTypes,
69 import TyVar ( unionTyVarSets, GenTyVar )
70 import TysPrim ( intPrimTy )
71 import TysWiredIn ( intDataCon, integerTy )
72 import Unique ( fromRationalClassOpKey, rationalTyConKey,
73 fromIntClassOpKey, fromIntegerClassOpKey, Unique
75 import Util ( panic, zipEqual, zipWithEqual, assoc, assertPanic, pprTrace{-ToDo:rm-} )
76 #if __GLASGOW_HASKELL__ >= 202
81 %************************************************************************
83 \subsection[Inst-collections]{LIE: a collection of Insts}
85 %************************************************************************
88 type LIE s = Bag (Inst s)
91 unitLIE inst = unitBag inst
92 plusLIE lie1 lie2 = lie1 `unionBags` lie2
93 consLIE inst lie = inst `consBag` lie
94 plusLIEs lies = unionManyBags lies
96 zonkLIE :: LIE s -> NF_TcM s (LIE s)
97 zonkLIE lie = mapBagNF_Tc zonkInst lie
99 pprLIE :: PprStyle -> LIE s -> Doc
100 pprLIE sty lie = pprQuote sty $ \ sty ->
101 braces (hsep (punctuate comma (map (pprInst sty) (bagToList lie))))
104 pprLIEInFull sty insts
105 = vcat (map go (bagToList insts))
107 go inst = ppr sty inst <+> pprOrigin sty inst
110 %************************************************************************
112 \subsection[Inst-types]{@Inst@ types}
114 %************************************************************************
116 An @Inst@ is either a dictionary, an instance of an overloaded
117 literal, or an instance of an overloaded value. We call the latter a
118 ``method'' even though it may not correspond to a class operation.
119 For example, we might have an instance of the @double@ function at
120 type Int, represented by
122 Method 34 doubleId [Int] origin
128 Class -- The type of the dict is (c t), where
129 (TcType s) -- c is the class and t the type;
136 (TcIdOcc s) -- The overloaded function
137 -- This function will be a global, local, or ClassOpId;
138 -- inside instance decls (only) it can also be an InstId!
139 -- The id needn't be completely polymorphic.
140 -- You'll probably find its name (for documentation purposes)
141 -- inside the InstOrigin
143 [TcType s] -- The types to which its polymorphic tyvars
144 -- should be instantiated.
145 -- These types must saturate the Id's foralls.
147 (TcRhoType s) -- Cached: (type-of-id applied to inst_tys)
148 -- If this type is (theta => tau) then the type of the Method
149 -- is tau, and the method can be built by saying
151 -- where dicts are constructed from theta
159 (TcType s) -- The type at which the literal is used
160 (InstOrigin s) -- Always a literal; but more convenient to carry this around
164 = OverloadedIntegral Integer -- The number
165 | OverloadedFractional Rational -- The number
167 getInstOrigin (Dict u clas ty origin loc) = origin
168 getInstOrigin (Method u clas ty rho origin loc) = origin
169 getInstOrigin (LitInst u lit ty origin loc) = origin
176 newDicts :: InstOrigin s
177 -> [(Class, TcType s)]
178 -> NF_TcM s (LIE s, [TcIdOcc s])
180 = tcGetSrcLoc `thenNF_Tc` \ loc ->
181 newDictsAtLoc orig loc theta `thenNF_Tc` \ (dicts, ids) ->
182 returnNF_Tc (listToBag dicts, ids)
184 tcGetUniques (length theta) `thenNF_Tc` \ new_uniqs ->
186 mk_dict u (clas, ty) = Dict u clas ty orig loc
187 dicts = zipWithEqual "newDicts" mk_dict new_uniqs theta
189 returnNF_Tc (listToBag dicts, map instToId dicts)
192 -- Local function, similar to newDicts,
193 -- but with slightly different interface
194 newDictsAtLoc :: InstOrigin s
196 -> [(Class, TcType s)]
197 -> NF_TcM s ([Inst s], [TcIdOcc s])
198 newDictsAtLoc orig loc theta =
199 tcGetUniques (length theta) `thenNF_Tc` \ new_uniqs ->
201 mk_dict u (clas, ty) = Dict u clas ty orig loc
202 dicts = zipWithEqual "newDictsAtLoc" mk_dict new_uniqs theta
204 returnNF_Tc (dicts, map instToId dicts)
206 newMethod :: InstOrigin s
209 -> NF_TcM s (LIE s, TcIdOcc s)
210 newMethod orig id tys
211 = -- Get the Id type and instantiate it at the specified types
213 RealId id -> let (tyvars, rho) = splitForAllTy (idType id)
215 (if length tyvars /= length tys then pprTrace "newMethod" (ppr PprDebug (idType id)) else \x->x) $
216 tcInstType (zip{-Equal "newMethod"-} tyvars tys) rho
217 TcId id -> tcSplitForAllTy (idType id) `thenNF_Tc` \ (tyvars, rho) ->
218 returnNF_Tc (instantiateTy (zipEqual "newMethod(2)" tyvars tys) rho)
219 ) `thenNF_Tc` \ rho_ty ->
220 -- Our friend does the rest
221 newMethodWithGivenTy orig id tys rho_ty
224 newMethodWithGivenTy orig id tys rho_ty
225 = tcGetSrcLoc `thenNF_Tc` \ loc ->
226 tcGetUnique `thenNF_Tc` \ new_uniq ->
228 meth_inst = Method new_uniq id tys rho_ty orig loc
230 returnNF_Tc (unitLIE meth_inst, instToId meth_inst)
232 newMethodAtLoc :: InstOrigin s -> SrcLoc -> Id -> [TcType s] -> NF_TcM s (Inst s, TcIdOcc s)
233 newMethodAtLoc orig loc real_id tys -- Local function, similar to newMethod but with
234 -- slightly different interface
235 = -- Get the Id type and instantiate it at the specified types
237 (tyvars,rho) = splitForAllTy (idType real_id)
239 tcInstType (zipEqual "newMethodAtLoc" tyvars tys) rho `thenNF_Tc` \ rho_ty ->
240 tcGetUnique `thenNF_Tc` \ new_uniq ->
242 meth_inst = Method new_uniq (RealId real_id) tys rho_ty orig loc
244 returnNF_Tc (meth_inst, instToId meth_inst)
246 newOverloadedLit :: InstOrigin s
249 -> NF_TcM s (LIE s, TcIdOcc s)
250 newOverloadedLit orig lit ty
251 = tcGetSrcLoc `thenNF_Tc` \ loc ->
252 tcGetUnique `thenNF_Tc` \ new_uniq ->
254 lit_inst = LitInst new_uniq lit ty orig loc
256 returnNF_Tc (unitLIE lit_inst, instToId lit_inst)
261 instToId :: Inst s -> TcIdOcc s
262 instToId (Dict u clas ty orig loc)
263 = TcId (mkInstId u (mkDictTy clas ty) (mkLocalName u str loc))
265 str = VarOcc (SLIT("d.") _APPEND_ (occNameString (getOccName clas)))
267 instToId (Method u id tys rho_ty orig loc)
268 = TcId (mkInstId u tau_ty (mkLocalName u occ loc))
271 (_, tau_ty) = splitRhoTy rho_ty
272 -- I hope we don't need tcSplitRhoTy...
273 -- NB The method Id has just the tau type
275 instToId (LitInst u list ty orig loc)
276 = TcId (mkInstId u ty (mkSysLocalName u SLIT("lit") loc))
280 instType :: Inst s -> TcType s
281 instType (Dict _ clas ty _ _) = mkDictTy clas ty
282 instType (LitInst _ _ ty _ _) = ty
283 instType (Method _ id tys ty _ _) = ty
289 Zonking makes sure that the instance types are fully zonked,
290 but doesn't do the same for the Id in a Method. There's no
291 need, and it's a lot of extra work.
294 zonkInst :: Inst s -> NF_TcM s (Inst s)
295 zonkInst (Dict u clas ty orig loc)
296 = zonkTcType ty `thenNF_Tc` \ new_ty ->
297 returnNF_Tc (Dict u clas new_ty orig loc)
299 zonkInst (Method u id tys rho orig loc) -- Doesn't zonk the id!
300 = mapNF_Tc zonkTcType tys `thenNF_Tc` \ new_tys ->
301 zonkTcType rho `thenNF_Tc` \ new_rho ->
302 returnNF_Tc (Method u id new_tys new_rho orig loc)
304 zonkInst (LitInst u lit ty orig loc)
305 = zonkTcType ty `thenNF_Tc` \ new_ty ->
306 returnNF_Tc (LitInst u lit new_ty orig loc)
311 tyVarsOfInst :: Inst s -> TcTyVarSet s
312 tyVarsOfInst (Dict _ _ ty _ _) = tyVarsOfType ty
313 tyVarsOfInst (Method _ id tys rho _ _) = tyVarsOfTypes tys `unionTyVarSets` tcIdTyVars id
314 -- The id might not be a RealId; in the case of
315 -- locally-overloaded class methods, for example
316 tyVarsOfInst (LitInst _ _ ty _ _) = tyVarsOfType ty
319 @matchesInst@ checks when two @Inst@s are instances of the same
320 thing at the same type, even if their uniques differ.
323 matchesInst :: Inst s -> Inst s -> Bool
325 matchesInst (Dict _ clas1 ty1 _ _) (Dict _ clas2 ty2 _ _)
326 = clas1 == clas2 && ty1 `eqSimpleTy` ty2
328 matchesInst (Method _ id1 tys1 _ _ _) (Method _ id2 tys2 _ _ _)
330 && and (zipWith eqSimpleTy tys1 tys2)
331 && length tys1 == length tys2
333 matchesInst (LitInst _ lit1 ty1 _ _) (LitInst _ lit2 ty2 _ _)
334 = lit1 `eq` lit2 && ty1 `eqSimpleTy` ty2
336 (OverloadedIntegral i1) `eq` (OverloadedIntegral i2) = i1 == i2
337 (OverloadedFractional f1) `eq` (OverloadedFractional f2) = f1 == f2
340 matchesInst other1 other2 = False
347 isDict :: Inst s -> Bool
348 isDict (Dict _ _ _ _ _) = True
351 isTyVarDict :: Inst s -> Bool
352 isTyVarDict (Dict _ _ ty _ _) = isTyVarTy ty
353 isTyVarDict other = False
356 Two predicates which deal with the case where class constraints don't
357 necessarily result in bindings. The first tells whether an @Inst@
358 must be witnessed by an actual binding; the second tells whether an
359 @Inst@ can be generalised over.
362 instBindingRequired :: Inst s -> Bool
363 instBindingRequired (Dict _ clas _ _ _) = not (isNoDictClass clas)
364 instBindingRequired other = True
366 instCanBeGeneralised :: Inst s -> Bool
367 instCanBeGeneralised (Dict _ clas _ _ _) = not (isCcallishClass clas)
368 instCanBeGeneralised other = True
374 ToDo: improve these pretty-printing things. The ``origin'' is really only
375 relevant in error messages.
378 instance Outputable (Inst s) where
379 ppr sty inst = pprQuote sty (\ sty -> pprInst sty inst)
381 pprInst sty (LitInst u lit ty orig loc)
383 OverloadedIntegral i -> integer i
384 OverloadedFractional f -> rational f,
389 pprInst sty (Dict u clas ty orig loc)
390 = hsep [ppr sty clas, pprParendGenType sty ty, show_uniq sty u]
392 pprInst sty (Method u id tys rho orig loc)
393 = hsep [ppr sty id, ptext SLIT("at"),
397 show_uniq PprDebug u = ppr PprDebug u
398 show_uniq sty u = empty
401 Printing in error messages
404 noInstanceErr inst sty = ptext SLIT("No instance for:") <+> ppr sty inst
407 %************************************************************************
409 \subsection[InstEnv-types]{Type declarations}
411 %************************************************************************
414 type InstanceMapper = Class -> ClassInstEnv
417 A @ClassInstEnv@ lives inside a class, and identifies all the instances
418 of that class. The @Id@ inside a ClassInstEnv mapping is the dfun for
421 There is an important consistency constraint between the @MatchEnv@s
422 in and the dfun @Id@s inside them: the free type variables of the
423 @Type@ key in the @MatchEnv@ must be a subset of the universally-quantified
424 type variables of the dfun. Thus, the @ClassInstEnv@ for @Eq@ might
425 contain the following entry:
427 [a] ===> dfun_Eq_List :: forall a. Eq a => Eq [a]
429 The "a" in the pattern must be one of the forall'd variables in
435 TcDictBinds s) -- The new binding
439 lookupInst dict@(Dict _ clas ty orig loc)
440 = case lookupMEnv matchTy (get_inst_env clas orig) ty of
441 Nothing -> tcAddSrcLoc loc $
442 tcAddErrCtxt (\sty -> pprOrigin sty dict) $
443 failTc (noInstanceErr dict)
447 (tyvars, rho) = splitForAllTy (idType dfun_id)
448 ty_args = map (assoc "lookupInst" tenv) tyvars
449 -- tenv should bind all the tyvars
451 tcInstType tenv rho `thenNF_Tc` \ dfun_rho ->
453 (theta, tau) = splitRhoTy dfun_rho
455 newDictsAtLoc orig loc theta `thenNF_Tc` \ (dicts, dict_ids) ->
457 rhs = mkHsDictApp (mkHsTyApp (HsVar (RealId dfun_id)) ty_args) dict_ids
459 returnTc (dicts, VarMonoBind (instToId dict) rhs)
464 lookupInst inst@(Method _ id tys rho orig loc)
465 = tcSplitRhoTy rho `thenNF_Tc` \ (theta, _) ->
466 newDictsAtLoc orig loc theta `thenNF_Tc` \ (dicts, dict_ids) ->
467 returnTc (dicts, VarMonoBind (instToId inst) (mkHsDictApp (mkHsTyApp (HsVar id) tys) dict_ids))
471 lookupInst inst@(LitInst u (OverloadedIntegral i) ty orig loc)
472 | i >= toInteger minInt && i <= toInteger maxInt
473 = -- It's overloaded but small enough to fit into an Int
474 tcLookupGlobalValueByKey fromIntClassOpKey `thenNF_Tc` \ from_int ->
475 newMethodAtLoc orig loc from_int [ty] `thenNF_Tc` \ (method_inst, method_id) ->
476 returnTc ([method_inst], VarMonoBind (instToId inst) (HsApp (HsVar method_id) int_lit))
479 = -- Alas, it is overloaded and a big literal!
480 tcLookupGlobalValueByKey fromIntegerClassOpKey `thenNF_Tc` \ from_integer ->
481 newMethodAtLoc orig loc from_integer [ty] `thenNF_Tc` \ (method_inst, method_id) ->
482 returnTc ([method_inst], VarMonoBind (instToId inst) (HsApp (HsVar method_id) (HsLitOut (HsInt i) integerTy)))
484 intprim_lit = HsLitOut (HsIntPrim i) intPrimTy
485 int_lit = HsApp (HsVar (RealId intDataCon)) intprim_lit
487 lookupInst inst@(LitInst u (OverloadedFractional f) ty orig loc)
488 = tcLookupGlobalValueByKey fromRationalClassOpKey `thenNF_Tc` \ from_rational ->
490 -- The type Rational isn't wired in so we have to conjure it up
491 tcLookupTyConByKey rationalTyConKey `thenNF_Tc` \ rational_tycon ->
493 rational_ty = mkSynTy rational_tycon []
494 rational_lit = HsLitOut (HsFrac f) rational_ty
496 newMethodAtLoc orig loc from_rational [ty] `thenNF_Tc` \ (method_inst, method_id) ->
497 returnTc ([method_inst], VarMonoBind (instToId inst) (HsApp (HsVar method_id) rational_lit))
500 There is a second, simpler interface, when you want an instance of a
501 class at a given nullary type constructor. It just returns the
502 appropriate dictionary if it exists. It is used only when resolving
503 ambiguous dictionaries.
506 lookupSimpleInst :: ClassInstEnv
508 -> Type -- Look up (c,t)
509 -> TcM s [(Class,Type)] -- Here are the needed (c,t)s
511 lookupSimpleInst class_inst_env clas ty
512 = case (lookupMEnv matchTy class_inst_env ty) of
513 Nothing -> failTc (noSimpleInst clas ty)
514 Just (dfun,tenv) -> returnTc [(c,instantiateTy tenv t) | (c,t) <- theta]
516 (_, theta, _) = splitSigmaTy (idType dfun)
518 noSimpleInst clas ty sty
519 = ptext SLIT("No instance for") <+>
520 (pprQuote sty $ \ sty -> ppr sty clas <+> ppr sty ty)
524 @mkInstSpecEnv@ is used to construct the @SpecEnv@ for a dfun.
525 It does it by filtering the class's @InstEnv@. All pretty shady stuff.
528 mkInstSpecEnv clas inst_ty inst_tvs inst_theta = panic "mkInstSpecEnv"
532 mkInstSpecEnv :: Class -- class
533 -> Type -- instance type
534 -> [TyVarTemplate] -- instance tyvars
535 -> ThetaType -- superclasses dicts
536 -> SpecEnv -- specenv for dfun of instance
538 mkInstSpecEnv clas inst_ty inst_tvs inst_theta
539 = mkSpecEnv (catMaybes (map maybe_spec_info matches))
541 matches = matchMEnv matchTy (classInstEnv clas) inst_ty
543 maybe_spec_info (_, match_info, MkInstTemplate dfun _ [])
544 = Just (SpecInfo (map (assocMaybe match_info) inst_tvs) (length inst_theta) dfun)
545 maybe_spec_info (_, match_info, _)
552 :: ClassInstEnv -- Incoming envt
553 -> Type -- The instance type: inst_ty
554 -> Id -- Dict fun id to apply. Free tyvars of inst_ty must
555 -- be the same as the forall'd tyvars of the dfun id.
557 ClassInstEnv -- Success
558 (Type, Id) -- Offending overlap
560 addClassInst inst_env inst_ty dfun_id = insertMEnv matchTy inst_env inst_ty dfun_id
565 %************************************************************************
567 \subsection[Inst-origin]{The @InstOrigin@ type}
569 %************************************************************************
571 The @InstOrigin@ type gives information about where a dictionary came from.
572 This is important for decent error message reporting because dictionaries
573 don't appear in the original source code. Doubtless this type will evolve...
577 = OccurrenceOf (TcIdOcc s) -- Occurrence of an overloaded identifier
578 | OccurrenceOfCon Id -- Occurrence of a data constructor
582 | DataDeclOrigin -- Typechecking a data declaration
584 | InstanceDeclOrigin -- Typechecking an instance decl
586 | LiteralOrigin HsLit -- Occurrence of a literal
588 | ArithSeqOrigin RenamedArithSeqInfo -- [x..], [x..y] etc
590 | SignatureOrigin -- A dict created from a type signature
592 | DoOrigin -- The monad for a do expression
594 | ClassDeclOrigin -- Manufactured during a class decl
597 -- | DerivingOrigin InstanceMapper
601 -- During "deriving" operations we have an ever changing
602 -- mapping of classes to instances, so we record it inside the
603 -- origin information. This is a bit of a hack, but it works
604 -- fine. (Simon is to blame [WDP].)
606 | InstanceSpecOrigin InstanceMapper
607 Class -- in a SPECIALIZE instance pragma
610 -- When specialising instances the instance info attached to
611 -- each class is not yet ready, so we record it inside the
612 -- origin information. This is a bit of a hack, but it works
613 -- fine. (Patrick is to blame [WDP].)
615 -- | DefaultDeclOrigin -- Related to a `default' declaration
617 | ValSpecOrigin Name -- in a SPECIALIZE pragma for a value
619 -- Argument or result of a ccall
620 -- Dictionaries with this origin aren't actually mentioned in the
621 -- translated term, and so need not be bound. Nor should they
622 -- be abstracted over.
624 | CCallOrigin String -- CCall label
625 (Maybe RenamedHsExpr) -- Nothing if it's the result
626 -- Just arg, for an argument
628 | LitLitOrigin String -- the litlit
630 | UnknownOrigin -- Help! I give up...
634 -- During deriving and instance specialisation operations
635 -- we can't get the instances of the class from inside the
636 -- class, because the latter ain't ready yet. Instead we
637 -- find a mapping from classes to envts inside the dict origin.
639 get_inst_env :: Class -> InstOrigin s -> ClassInstEnv
640 -- get_inst_env clas (DerivingOrigin inst_mapper _ _)
641 -- = fst (inst_mapper clas)
642 get_inst_env clas (InstanceSpecOrigin inst_mapper _ _)
644 get_inst_env clas other_orig = classInstEnv clas
647 pprOrigin :: PprStyle -> Inst s -> Doc
649 = hsep [text "arising from", pp_orig orig, text "at", ppr sty locn]
651 (orig, locn) = case inst of
652 Dict _ _ _ orig loc -> (orig,loc)
653 Method _ _ _ _ orig loc -> (orig,loc)
654 LitInst _ _ _ orig loc -> (orig,loc)
656 pp_orig (OccurrenceOf id)
657 = hsep [ptext SLIT("use of"), ppr sty id]
658 pp_orig (OccurrenceOfCon id)
659 = hsep [ptext SLIT("use of"), ppr sty id]
660 pp_orig (LiteralOrigin lit)
661 = hsep [ptext SLIT("the literal"), ppr sty lit]
662 pp_orig (InstanceDeclOrigin)
663 = ptext SLIT("an instance declaration")
664 pp_orig (ArithSeqOrigin seq)
665 = hsep [ptext SLIT("the arithmetic sequence:"), ppr sty seq]
666 pp_orig (SignatureOrigin)
667 = ptext SLIT("a type signature")
669 = ptext SLIT("a do statement")
670 pp_orig (ClassDeclOrigin)
671 = ptext SLIT("a class declaration")
672 pp_orig (InstanceSpecOrigin _ clas ty)
673 = hsep [text "a SPECIALIZE instance pragma; class",
674 ppr sty clas, text "type:", ppr sty ty]
675 pp_orig (ValSpecOrigin name)
676 = hsep [ptext SLIT("a SPECIALIZE user-pragma for"), ppr sty name]
677 pp_orig (CCallOrigin clabel Nothing{-ccall result-})
678 = hsep [ptext SLIT("the result of the _ccall_ to"), text clabel]
679 pp_orig (CCallOrigin clabel (Just arg_expr))
680 = hsep [ptext SLIT("an argument in the _ccall_ to"), text clabel <> comma, text "namely", ppr sty arg_expr]
681 pp_orig (LitLitOrigin s)
682 = hsep [ptext SLIT("the ``literal-literal''"), text s]
683 pp_orig (UnknownOrigin)
684 = ptext SLIT("...oops -- I don't know where the overloading came from!")