2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1994
4 \section[TcDeriv]{Deriving}
6 Handles @deriving@ clauses on @data@ declarations.
8 ********** Don't forget
10 Multi-instance checking in renamer should include deriving.
13 #include "HsVersions.h"
17 con2tag_PN, tag2con_PN, maxtag_PN,
18 TagThingWanted(..), DerivEqn(..)
21 IMPORT_Trace -- ToDo:rm debugging
25 import TcMonad -- typechecking monad machinery
26 import TcMonadFns ( copyTyVars )
27 import AbsSyn -- the stuff being typechecked
28 import TcGenDeriv -- support code that generates all the grimy bindings
29 -- for derived instance decls.
31 import AbsPrel ( mkFunTy )
33 import UniType ( UniType(..) ) -- *********** CHEATING!!! ****************
36 import CmdLineOpts ( GlobalSwitch(..) )
39 import HsCore -- ****** NEED TO SEE CONSTRUCTORS ******
40 import HsPragmas -- InstancePragmas(..)
41 import Id ( getDataConSig, isNullaryDataCon, DataCon(..) )
43 import Inst ( InstOrigin(..) )
45 import Maybes ( assocMaybe, maybeToBool, Maybe(..) )
46 import NameTypes ( mkFullName, mkPreludeCoreName,
47 Provenance(..), FullName, ShortName
49 import ProtoName ( eqProtoName, ProtoName(..), Name )
50 import RenameAuxFuns -- why not? take all of it...
51 import RenameBinds4 ( rnMethodBinds4, rnTopBinds4 )
52 import RenameMonad4 -- initRn4, etc.
53 import SrcLoc ( mkGeneratedSrcLoc, mkUnknownSrcLoc, SrcLoc )
54 import TCE -- ( rngTCE, TCE(..), UniqFM )
55 import TcInstDcls ( InstInfo(..), buildInstanceEnvs, mkInstanceRelatedIds )
56 import TcSimplify ( tcSimplifyThetas )
57 import Unique -- *Key stuff
61 %************************************************************************
63 \subsection[TcDeriv-intro]{Introduction to how we do deriving}
65 %************************************************************************
69 data T a b = C1 (Foo a) (Bar b)
74 We want to come up with an instance declaration of the form
76 instance (Ping a, Pong b, ...) => Eq (T a b) where
79 It is pretty easy, albeit tedious, to fill in the code "...". The
80 trick is to figure out what the context for the instance decl is,
81 namely @Ping@, @Pong@ and friends.
83 Let's call the context reqd for the T instance of class C at types
84 (a,b, ...) C (T a b). Thus:
86 Eq (T a b) = (Ping a, Pong b, ...)
88 Now we can get a (recursive) equation from the @data@ decl:
90 Eq (T a b) = Eq (Foo a) u Eq (Bar b) -- From C1
91 u Eq (T b a) u Eq Int -- From C2
92 u Eq (T a a) -- From C3
94 Foo and Bar may have explicit instances for @Eq@, in which case we can
95 just substitute for them. Alternatively, either or both may have
96 their @Eq@ instances given by @deriving@ clauses, in which case they
97 form part of the system of equations.
99 Now all we need do is simplify and solve the equations, iterating to
100 find the least fixpoint. Notice that the order of the arguments can
101 switch around, as here in the recursive calls to T.
103 Let's suppose Eq (Foo a) = Eq a, and Eq (Bar b) = Ping b.
107 Eq (T a b) = {} -- The empty set
110 Eq (T a b) = Eq (Foo a) u Eq (Bar b) -- From C1
111 u Eq (T b a) u Eq Int -- From C2
112 u Eq (T a a) -- From C3
114 After simplification:
115 = Eq a u Ping b u {} u {} u {}
120 Eq (T a b) = Eq (Foo a) u Eq (Bar b) -- From C1
121 u Eq (T b a) u Eq Int -- From C2
122 u Eq (T a a) -- From C3
124 After simplification:
129 = Eq a u Ping b u Eq b u Ping a
131 The next iteration gives the same result, so this is the fixpoint. We
132 need to make a canonical form of the RHS to ensure convergence. We do
133 this by simplifying the RHS to a form in which
135 - the classes constrain only tyvars
136 - the list is sorted by tyvar (major key) and then class (minor key)
137 - no duplicates, of course
139 So, here are the synonyms for the ``equation'' structures:
142 type DerivEqn = (Class, TyCon, [TyVar], DerivRhs)
143 -- The tyvars bind all the variables in the RHS
144 -- NEW: it's convenient to re-use InstInfo
145 -- We'll "panic" out some fields...
147 type DerivRhs = [(Class, TauType)] -- Same as a ThetaType!
149 type DerivSoln = DerivRhs
152 %************************************************************************
154 \subsection[TcDeriv-driver]{Top-level function for \tr{derivings}}
156 %************************************************************************
159 tcDeriving :: FAST_STRING -- name of module under scrutiny
160 -> GlobalNameFuns -- for "renaming" bits of generated code
161 -> Bag InstInfo -- What we already know about instances
162 -> TCE -- All known TyCon info
163 -> [RenamedFixityDecl] -- Fixity info; may be used for Text
164 -> TcM (Bag InstInfo, -- The generated "instance decls".
165 RenamedBinds, -- Extra generated bindings
166 PprStyle -> Pretty) -- Printable derived instance decls;
167 -- for debugging via -ddump-derivings.
169 tcDeriving modname renamer_name_funs inst_decl_infos_in tce fixities
170 = -- Fish the "deriving"-related information out of the TCE,
171 -- from which we make the necessary "equations".
172 makeDerivEqns tce `thenTc` \ eqns ->
174 -- Take the equation list and solve it, to deliver a list of
175 -- solutions, a.k.a. the contexts for the instance decls
176 -- required for the corresponding equations.
177 solveDerivEqns modname inst_decl_infos_in eqns
178 `thenTc` \ new_inst_infos ->
180 -- Now augment the InstInfos, adding in the rather boring
181 -- actual-code-to-do-the-methods binds. We may also need to
182 -- generate extra not-one-inst-decl-specific binds, notably
183 -- "con2tag" and/or "tag2con" functions. We do these
186 gen_taggery_Names eqns `thenTc` \ nm_alist_etc ->
188 nm_alist = [ (pn, n) | (pn,n,_,_) <- nm_alist_etc ]
190 -- We have the renamer's final "name funs" in our hands
191 -- (they were passed in). So we can handle ProtoNames
192 -- that refer to anything "out there". But our generated
193 -- code may also mention "con2tag" (etc.). So we need
194 -- to augment to "name funs" to include those.
195 (rn_val_gnf, rn_tc_gnf) = renamer_name_funs
197 deriv_val_gnf pname = case (assoc_maybe nm_alist pname) of
199 Nothing -> rn_val_gnf pname
201 deriver_name_funs = (deriv_val_gnf, rn_tc_gnf)
203 assoc_maybe [] _ = Nothing
204 assoc_maybe ((v,xxx) : vs) key
205 = if v `eqProtoName` key then Just xxx else assoc_maybe vs key
207 gen_tag_n_con_binds deriver_name_funs nm_alist_etc `thenTc` \ extra_binds ->
209 mapTc (gen_inst_info modname fixities deriver_name_funs) new_inst_infos
210 `thenTc` \ really_new_inst_infos ->
212 returnTc (listToBag really_new_inst_infos,
214 ddump_deriving really_new_inst_infos extra_binds)
216 ddump_deriving :: [InstInfo] -> RenamedBinds -> (PprStyle -> Pretty)
218 ddump_deriving inst_infos extra_binds sty
219 = ppAboves ((map (pp_1 sty) inst_infos) ++ [ppr sty extra_binds])
221 pp_1 sty (InstInfo clas tv_tmpls ty inst_decl_theta _ _ _ mbinds _ _ _ _)
222 = ppAbove (ppr sty (mkSigmaTy tv_tmpls inst_decl_theta
228 %************************************************************************
230 \subsection[TcDeriv-eqns]{Forming the equations}
232 %************************************************************************
234 @makeDerivEqns@ fishes around to find the info about needed derived
235 instances. Complicating factors:
238 We can only derive @Enum@ if the data type is an enumeration
239 type (all nullary data constructors).
242 We can only derive @Ix@ if the data type is an enumeration {\em
243 or} has just one data constructor (e.g., tuples).
246 [See Appendix~E in the Haskell~1.2 report.] This code here deals w/
250 makeDerivEqns :: TCE -> TcM [DerivEqn]
254 think_about_deriving = need_deriving (rngTCE tce)
256 mapTc (chk_out think_about_deriving) think_about_deriving `thenTc_`
259 (derive_these, _) = removeDups cmp think_about_deriving
262 listNF_Tc (map mk_eqn derive_these) `thenNF_Tc` \ eqns ->
266 ------------------------------------------------------------------
267 need_deriving :: [TyCon] -> [(Class, TyCon)]
268 -- find the tycons that have `deriving' clauses
270 need_deriving tycons_to_consider
271 = foldr ( \ tycon acc ->
272 case (getTyConDerivings tycon) of
274 cs -> [ (clas,tycon) | clas <- cs ] ++ acc
276 [] -- init accumulator
279 ------------------------------------------------------------------
280 chk_out :: [(Class, TyCon)] -> (Class, TyCon) -> TcM ()
282 chk_out whole_deriving_list this_one@(clas, tycon)
283 = -- Are the relevant superclasses catered for?
284 -- E.g., for "... deriving Ord", is there an
287 (_, super_classes, _) = getClassSig clas
288 clas_key = getClassKey clas
291 -- Are things OK for deriving Enum (if appropriate)?
292 checkTc (clas_key == enumClassKey && not (isEnumerationTyCon tycon))
293 (derivingEnumErr tycon) `thenTc_`
295 -- Are things OK for deriving Ix (if appropriate)?
296 checkTc (clas_key == ixClassKey
297 && not (isEnumerationTyCon tycon
298 || maybeToBool (maybeSingleConstructorTyCon tycon)))
299 (derivingIxErr tycon)
301 ------------------------------------------------------------------
302 cmp :: (Class, TyCon) -> (Class, TyCon) -> TAG_
304 cmp (c1, t1) (c2, t2)
305 = case cmpClass c1 c2 of
306 EQ_ -> cmpTyCon t1 t2
309 ------------------------------------------------------------------
310 mk_eqn :: (Class, TyCon) -> NF_TcM DerivEqn
311 -- we swizzle the tyvars, data cons, etc., out of the tycon,
312 -- to make the rest of the equation
316 tyvar_tmpls = getTyConTyVarTemplates tycon
317 data_cons = getTyConDataCons tycon
319 copyTyVars tyvar_tmpls `thenNF_Tc` \ (_, tyvars, tyvar_tys) ->
322 constraints = concat [mk_constraints tyvar_tys con | con <- data_cons]
324 returnNF_Tc (clas, tycon, tyvars, constraints)
326 mk_constraints tyvar_tys data_con
327 = [ (clas, instantiateTy inst_env arg_ty)
329 not (isPrimType arg_ty) -- No constraints for primitive types
332 (con_tyvar_tmpls, _, arg_tys, _) = getDataConSig data_con
333 inst_env = con_tyvar_tmpls `zipEqual` tyvar_tys
334 -- Type vars in data contructor should be same in number
335 -- as in the type contsructor!
338 %************************************************************************
340 \subsection[TcDeriv-fixpoint]{Finding the fixed point of \tr{deriving} equations}
342 %************************************************************************
344 A ``solution'' (to one of the equations) is a list of (k,UniTyVar tv)
345 terms, which is the final correct RHS for the corresponding original
349 Each (k,UniTyVarTemplate tv) in a solution constrains only a type
353 The (k,UniTyVarTemplate tv) pairs in a solution are canonically
354 ordered by sorting on type varible, tv, (major key) and then class, k,
359 solveDerivEqns :: FAST_STRING
362 -> TcM [InstInfo] -- Solns in same order as eqns.
363 -- This bunch is Absolutely minimal...
365 solveDerivEqns modname inst_decl_infos_in orig_eqns
366 = iterateDeriv initial_solutions
368 -- The initial solutions for the equations claim that each
369 -- instance has an empty context; this solution is certainly
370 -- in canonical form.
371 initial_solutions :: [DerivSoln]
372 initial_solutions = [ [] | _ <- orig_eqns ]
374 -- iterateDeriv calculates the next batch of solutions,
375 -- compares it with the current one; finishes if they are the
376 -- same, otherwise recurses with the new solutions.
378 iterateDeriv :: [DerivSoln] ->TcM [InstInfo]
380 iterateDeriv current_solns
381 = -- Extend the inst info from the explicit instance decls
382 -- with the current set of solutions, giving a
384 add_solns modname inst_decl_infos_in orig_eqns current_solns
385 `thenTc` \ (new_inst_infos, inst_mapper) ->
387 -- Simplify each RHS, using a DerivingOrigin containing an
388 -- inst_mapper reflecting the previous solution
390 mk_deriv_origin clas ty
391 = DerivingOrigin inst_mapper clas is_fun_type tycon locn
393 is_fun_type = isFunType ty
394 (tycon,_,_) = getUniDataTyCon ty
395 locn = if is_fun_type then mkUnknownSrcLoc{-sigh-} else getSrcLoc tycon
397 listTc [ tcSimplifyThetas mk_deriv_origin rhs
398 | (_, _, _, rhs) <- orig_eqns
399 ] `thenTc` \ next_solns ->
401 -- Canonicalise the solutions, so they compare nicely
402 let canonicalised_next_solns
403 = [ sortLt less_than next_soln | next_soln <- next_solns ] in
405 if current_solns == canonicalised_next_solns then
406 returnTc new_inst_infos
408 iterateDeriv canonicalised_next_solns
411 ------------------------------------------------------------------
412 less_than :: (Class, TauType) -> (Class, TauType) -> Bool
414 less_than (clas1, UniTyVar tv1) (clas2, UniTyVar tv2)
415 = tv1 < tv2 || (tv1 == tv2 && clas1 < clas2)
417 less_than other_1 other_2
418 = pprPanic "tcDeriv:less_than:" (ppCat [ppr PprDebug other_1, ppr PprDebug other_2])
423 add_solns :: FAST_STRING
424 -> Bag InstInfo -- The global, non-derived ones
425 -> [DerivEqn] -> [DerivSoln]
426 -> TcM ([InstInfo], -- The new, derived ones
428 -- the eqns and solns move "in lockstep"; we have the eqns
429 -- because we need the LHS info for addClassInstance.
431 add_solns modname inst_infos_in eqns solns
432 = listTc (zipWith mk_deriv_inst_info eqns solns) `thenTc` \ new_inst_infos ->
434 buildInstanceEnvs (inst_infos_in `unionBags`
435 listToBag new_inst_infos) `thenTc` \ inst_mapper ->
437 returnTc (new_inst_infos, inst_mapper)
439 mk_deriv_inst_info (clas, tycon, tyvars, _) theta
440 -- The complication here is rather boring: InstInfos need TyVarTemplates,
441 -- and we have only TyVars in our hand.
443 tyvar_tmpls = mkTemplateTyVars tyvars
444 tv_tmpl_tys = map mkTyVarTemplateTy tyvar_tmpls
446 env = tyvars `zipEqual` tv_tmpl_tys
448 tycon_tmpl_ty = applyTyCon tycon tv_tmpl_tys
449 theta_tmpl = [(clas, mapOverTyVars to_tmpl ty) | (clas,ty) <- theta]
451 to_tmpl = assoc "mk_deriv_inst_info" env
453 (class_tyvar, super_classes, _, class_ops, _, _) = getClassBigSig clas
456 InstInfo clas tyvar_tmpls tycon_tmpl_ty
458 theta_tmpl -- Blarg. This is the dfun_theta slot,
459 -- which is needed by buildInstanceEnv;
460 -- This works ok for solving the eqns, and
461 -- gen_eqns sets it to its final value
462 -- (incl super class dicts) before we
463 -- finally return it.
465 (panic "add_soln:dfun_id") (panic "add_soln:const_meth_ids")
466 (panic "add_soln:binds") (panic "add_soln:from_here")
467 (panic "add_soln:modname") mkGeneratedSrcLoc
468 (panic "add_soln:upragmas")
471 bottom bottom bottom bottom bottom mkGeneratedSrcLoc bottom
474 bottom = panic "add_soln"
478 %************************************************************************
480 \subsection[TcDeriv-normal-binds]{Bindings for the various classes}
482 %************************************************************************
484 After all the trouble to figure out the required context for the
485 derived instance declarations, all that's left is to chug along to
486 produce them. They will then be shoved into @tcInstDecls2@, which
487 will do all its usual business.
489 There are lots of possibilities for code to generate. Here are
490 various general remarks.
495 We want derived instances of @Eq@ and @Ord@ (both v common) to be
496 ``you-couldn't-do-better-by-hand'' efficient.
499 Deriving @Text@---also pretty common, usually just for
500 @show@---should also be reasonable good code.
503 Deriving for the other classes isn't that common or that big a deal.
510 Deriving @Ord@ is done mostly with our non-standard @tagCmp@ method.
513 Deriving @Eq@ also uses @tagCmp@, if we're deriving @Ord@, too.
516 We {\em normally} generated code only for the non-defaulted methods;
517 there are some exceptions for @Eq@ and (especially) @Ord@...
520 Sometimes we use a @_con2tag_<tycon>@ function, which returns a data
521 constructor's numeric (@Int#@) tag. These are generated by
522 @gen_tag_n_con_binds@, and the heuristic for deciding if one of
523 these is around is given by @hasCon2TagFun@.
526 The examples under the different sections below will make this
530 Much less often (really just for deriving @Ix@), we use a
531 @_tag2con_<tycon>@ function. See the examples.
534 We use Pass~4 of the renamer!!! Reason: we're supposed to be
535 producing @RenamedMonoBinds@ for the methods, but that means
536 producing correctly-uniquified code on the fly. This is entirely
537 possible (the @TcM@ monad has a @UniqueSupply@), but it is painful.
538 So, instead, we produce @ProtoNameMonoBinds@ then heave 'em through
539 the renamer. What a great hack!
543 gen_inst_info :: FAST_STRING -- Module name
544 -> [RenamedFixityDecl] -- all known fixities;
545 -- may be needed for Text
546 -> GlobalNameFuns -- lookup stuff for names we may use
547 -> InstInfo -- the main stuff to work on
548 -> TcM InstInfo -- the gen'd (filled-in) "instance decl"
550 gen_inst_info modname fixities deriver_name_funs
551 info@(InstInfo clas tyvar_tmpls ty inst_decl_theta _ _ _ _ _ _ locn _)
553 -- Generate the various instance-related Ids
555 (panic "add_solns:E")
556 -- These two are only needed if there are pragmas to typecheck;
557 -- but there ain't since we are generating the code right here.
558 True {-yes, from_here-}
564 [{-no user pragmas-}]
565 `thenTc` \ (dfun_id, dfun_theta, const_meth_ids) ->
567 -- Generate the bindings for the new instance declaration,
568 -- rename it, and check for errors
569 getSwitchCheckerTc `thenNF_Tc` \ sw_chkr ->
571 (tycon,_,_) = getUniDataTyCon ty
573 omit_readsPrec = sw_chkr OmitDerivedRead
576 = if clas_key == textClassKey then gen_Text_binds fixities omit_readsPrec tycon
577 else if clas_key == eqClassKey then gen_Eq_binds tycon
578 else if clas_key == ordClassKey then gen_Ord_binds tycon
579 else if clas_key == enumClassKey then gen_Enum_binds tycon
580 else if clas_key == ixClassKey then gen_Ix_binds tycon
581 else if clas_key == binaryClassKey then gen_Binary_binds tycon
582 else panic "gen_inst_info:bad derived class"
584 rn4MtoTcM deriver_name_funs (
585 rnMethodBinds4 clas_Name proto_mbinds
586 ) `thenNF_Tc` \ (mbinds, errs) ->
588 if not (isEmptyBag errs) then
589 pprPanic "gen_inst_info:renamer errs!\n" (ppAbove (pprBagOfErrors PprDebug errs) (ppr PprDebug proto_mbinds))
591 -- pprTrace "derived binds:" (ppr PprDebug proto_mbinds) $
595 from_here = isLocallyDefined tycon -- If so, then from here
597 returnTc (InstInfo clas tyvar_tmpls ty
598 inst_decl_theta dfun_theta dfun_id const_meth_ids
599 -- and here comes the main point...
600 (if from_here then mbinds else EmptyMonoBinds)
601 from_here modname locn [])
603 clas_key = getClassKey clas
605 = let (mod, nm) = getOrigName clas in
606 PreludeClass clas_key (mkPreludeCoreName mod nm)
609 %************************************************************************
611 \subsection[TcGenDeriv-con2tag-tag2con]{Generating extra binds (@con2tag@ and @tag2con@)}
613 %************************************************************************
617 con2tag_Foo :: Foo ... -> Int#
618 tag2con_Foo :: Int -> Foo ... -- easier if Int, not Int#
619 maxtag_Foo :: Int -- ditto (NB: not unboxed)
622 gen_tag_n_con_binds :: GlobalNameFuns
623 -> [(ProtoName, Name, TyCon, TagThingWanted)]
626 gen_tag_n_con_binds deriver_name_funs nm_alist_etc
628 proto_mbind_list = map gen_tag_n_con_monobind nm_alist_etc
629 proto_mbinds = foldr AndMonoBinds EmptyMonoBinds proto_mbind_list
632 rn4MtoTcM deriver_name_funs (
633 rnTopBinds4 (SingleBind (RecBind proto_mbinds))
634 ) `thenNF_Tc` \ (binds, errs) ->
636 if not (isEmptyBag errs) then
637 panic "gen_inst_info:renamer errs (2)!"
642 %************************************************************************
644 \subsection[TcDeriv-taggery-Names]{What con2tag/tag2con functions are available?}
646 %************************************************************************
648 We have a @con2tag@ function for a tycon if:
651 We're deriving @Eq@ and the tycon has nullary data constructors.
654 Or: we're deriving @Ord@ (unless single-constructor), @Enum@, @Ix@
658 We have a @tag2con@ function for a tycon if:
661 We're deriving @Enum@, or @Ix@ (enum type only???)
664 If we have a @tag2con@ function, we also generate a @maxtag@ constant.
668 = GenCon2Tag | GenTag2Con | GenMaxTag
670 gen_taggery_Names :: [DerivEqn]
671 -> TcM [(ProtoName, Name, -- for an assoc list
672 TyCon, -- related tycon
675 gen_taggery_Names eqns
676 = let all_tycons = [ tc | (_, tc, _, _) <- eqns ]
677 (tycons_of_interest, _) = removeDups cmpTyCon all_tycons
679 foldlTc do_con2tag [] tycons_of_interest `thenTc` \ names_so_far ->
680 foldlTc do_tag2con names_so_far tycons_of_interest
682 do_con2tag acc_Names tycon
683 = if (we_are_deriving eqClassKey tycon
684 && any isNullaryDataCon (getTyConDataCons tycon))
685 || (we_are_deriving ordClassKey tycon
686 && not (maybeToBool (maybeSingleConstructorTyCon tycon)))
687 || (we_are_deriving enumClassKey tycon)
688 || (we_are_deriving ixClassKey tycon)
690 getUniqueTc `thenNF_Tc` ( \ u ->
691 returnTc ((con2tag_PN tycon, OtherTopId u (con2tag_FN tycon), tycon, GenCon2Tag)
696 do_tag2con acc_Names tycon
697 = if (we_are_deriving enumClassKey tycon)
698 || (we_are_deriving ixClassKey tycon)
700 getUniqueTc `thenNF_Tc` \ u1 ->
701 getUniqueTc `thenNF_Tc` \ u2 ->
702 returnTc ( (tag2con_PN tycon, OtherTopId u1 (tag2con_FN tycon), tycon, GenTag2Con)
703 : (maxtag_PN tycon, OtherTopId u2 (maxtag_FN tycon), tycon, GenMaxTag)
708 we_are_deriving clas_key tycon
709 = is_in_eqns clas_key tycon eqns
711 is_in_eqns clas_key tycon [] = False
712 is_in_eqns clas_key tycon ((c,t,_,_):eqns) -- ToDo: InstInfo
713 = (clas_key == getClassKey c && tycon == t)
714 || is_in_eqns clas_key tycon eqns
716 con2tag_PN, tag2con_PN, maxtag_PN :: TyCon -> ProtoName
717 con2tag_FN, tag2con_FN, maxtag_FN :: TyCon -> FullName
720 = let (mod, nm) = getOrigName tycon
721 con2tag = SLIT("con2tag_") _APPEND_ nm _APPEND_ SLIT("#")
723 Imp mod con2tag [mod] con2tag
726 = let (mod, nm) = getOrigName tycon
727 con2tag = SLIT("con2tag_") _APPEND_ nm _APPEND_ SLIT("#")
729 mkFullName mod con2tag InventedInThisModule NotExported mkGeneratedSrcLoc
732 = let (mod, nm) = getOrigName tycon
733 tag2con = SLIT("tag2con_") _APPEND_ nm _APPEND_ SLIT("#")
735 Imp mod tag2con [mod] tag2con
738 = let (mod, nm) = getOrigName tycon
739 tag2con = SLIT("tag2con_") _APPEND_ nm _APPEND_ SLIT("#")
741 mkFullName mod tag2con InventedInThisModule NotExported mkGeneratedSrcLoc
744 = let (mod, nm) = getOrigName tycon
745 maxtag = SLIT("maxtag_") _APPEND_ nm _APPEND_ SLIT("#")
747 Imp mod maxtag [mod] maxtag
750 = let (mod, nm) = getOrigName tycon
751 maxtag = SLIT("maxtag_") _APPEND_ nm _APPEND_ SLIT("#")
753 mkFullName mod maxtag InventedInThisModule NotExported mkGeneratedSrcLoc