2 % (c) The AQUA Project, Glasgow University, 1998
4 \section[StdIdInfo]{Standard unfoldings}
6 This module contains definitions for the IdInfo for things that
7 have a standard form, namely:
11 * method and superclass selectors
12 * primitive operations
16 mkDictFunId, mkDefaultMethodId,
21 mkPrimOpId, mkFCallId,
23 mkReboxingAlt, wrapNewTypeBody, unwrapNewTypeBody,
24 mkUnpackCase, mkProductBox,
26 -- And some particular Ids; see below for why they are wired in
27 wiredInIds, ghcPrimIds,
28 unsafeCoerceId, realWorldPrimId, voidArgId, nullAddrId, seqId,
29 lazyId, lazyIdUnfolding, lazyIdKey,
32 rEC_CON_ERROR_ID, iRREFUT_PAT_ERROR_ID, rUNTIME_ERROR_ID,
33 nON_EXHAUSTIVE_GUARDS_ERROR_ID, nO_METHOD_BINDING_ERROR_ID,
34 pAT_ERROR_ID, eRROR_ID,
39 #include "HsVersions.h"
42 import BasicTypes ( Arity, StrictnessMark(..), isMarkedUnboxed, isMarkedStrict )
43 import Rules ( mkSpecInfo )
44 import TysPrim ( openAlphaTyVars, alphaTyVar, alphaTy,
45 realWorldStatePrimTy, addrPrimTy
47 import TysWiredIn ( charTy, mkListTy )
48 import PrelRules ( primOpRules )
49 import Type ( TyThing(..), mkForAllTy, tyVarsOfTypes,
50 newTyConInstRhs, mkTopTvSubst, substTyVar,
51 substTys, zipTopTvSubst )
52 import TcGadt ( gadtRefine, refineType, emptyRefinement )
53 import HsBinds ( HsWrapper(..), isIdHsWrapper )
54 import Coercion ( mkSymCoercion, mkUnsafeCoercion, isEqPred )
55 import TcType ( Type, ThetaType, mkDictTy, mkPredTys, mkPredTy,
56 mkTyConApp, mkTyVarTys, mkClassPred, isPredTy,
57 mkFunTys, mkFunTy, mkSigmaTy, tcSplitSigmaTy, tcEqType,
58 isUnLiftedType, mkForAllTys, mkTyVarTy, tyVarsOfType,
59 tcSplitFunTys, tcSplitForAllTys, dataConsStupidTheta
61 import CoreUtils ( exprType, dataConOrigInstPat, mkCoerce )
62 import CoreUnfold ( mkTopUnfolding, mkCompulsoryUnfolding )
63 import Literal ( nullAddrLit, mkStringLit )
64 import TyCon ( TyCon, isNewTyCon, tyConTyVars, tyConDataCons,
66 tyConStupidTheta, isProductTyCon, isDataTyCon,
67 isRecursiveTyCon, isFamInstTyCon,
68 tyConFamInst_maybe, tyConFamilyCoercion_maybe,
70 import Class ( Class, classTyCon, classSelIds )
71 import Var ( Id, TyVar, Var, setIdType )
72 import VarSet ( isEmptyVarSet, subVarSet, varSetElems )
73 import Name ( mkFCallName, mkWiredInName, Name, BuiltInSyntax(..))
74 import OccName ( mkOccNameFS, varName )
75 import PrimOp ( PrimOp, primOpSig, primOpOcc, primOpTag )
76 import ForeignCall ( ForeignCall )
77 import DataCon ( DataCon, DataConIds(..), dataConTyCon,
79 dataConFieldLabels, dataConRepArity, dataConResTys,
80 dataConRepArgTys, dataConRepType, dataConFullSig,
81 dataConStrictMarks, dataConExStricts,
82 splitProductType, isVanillaDataCon, dataConFieldType,
85 import Id ( idType, mkGlobalId, mkVanillaGlobal, mkSysLocal,
86 mkTemplateLocals, mkTemplateLocalsNum, mkExportedLocalId,
87 mkTemplateLocal, idName
89 import IdInfo ( IdInfo, noCafIdInfo, setUnfoldingInfo,
90 setArityInfo, setSpecInfo, setCafInfo,
91 setAllStrictnessInfo, vanillaIdInfo,
92 GlobalIdDetails(..), CafInfo(..)
94 import NewDemand ( mkStrictSig, DmdResult(..),
95 mkTopDmdType, topDmd, evalDmd, lazyDmd, retCPR,
96 Demand(..), Demands(..) )
97 import DmdAnal ( dmdAnalTopRhs )
99 import Unique ( mkBuiltinUnique, mkPrimOpIdUnique )
102 import Util ( dropList, isSingleton )
105 import ListSetOps ( assoc, minusList )
108 %************************************************************************
110 \subsection{Wired in Ids}
112 %************************************************************************
116 = [ -- These error-y things are wired in because we don't yet have
117 -- a way to express in an interface file that the result type variable
118 -- is 'open'; that is can be unified with an unboxed type
120 -- [The interface file format now carry such information, but there's
121 -- no way yet of expressing at the definition site for these
122 -- error-reporting functions that they have an 'open'
123 -- result type. -- sof 1/99]
125 eRROR_ID, -- This one isn't used anywhere else in the compiler
126 -- But we still need it in wiredInIds so that when GHC
127 -- compiles a program that mentions 'error' we don't
128 -- import its type from the interface file; we just get
129 -- the Id defined here. Which has an 'open-tyvar' type.
132 iRREFUT_PAT_ERROR_ID,
133 nON_EXHAUSTIVE_GUARDS_ERROR_ID,
134 nO_METHOD_BINDING_ERROR_ID,
141 -- These Ids are exported from GHC.Prim
143 = [ -- These can't be defined in Haskell, but they have
144 -- perfectly reasonable unfoldings in Core
152 %************************************************************************
154 \subsection{Data constructors}
156 %************************************************************************
158 The wrapper for a constructor is an ordinary top-level binding that evaluates
159 any strict args, unboxes any args that are going to be flattened, and calls
162 We're going to build a constructor that looks like:
164 data (Data a, C b) => T a b = T1 !a !Int b
167 \d1::Data a, d2::C b ->
168 \p q r -> case p of { p ->
170 Con T1 [a,b] [p,q,r]}}
174 * d2 is thrown away --- a context in a data decl is used to make sure
175 one *could* construct dictionaries at the site the constructor
176 is used, but the dictionary isn't actually used.
178 * We have to check that we can construct Data dictionaries for
179 the types a and Int. Once we've done that we can throw d1 away too.
181 * We use (case p of q -> ...) to evaluate p, rather than "seq" because
182 all that matters is that the arguments are evaluated. "seq" is
183 very careful to preserve evaluation order, which we don't need
186 You might think that we could simply give constructors some strictness
187 info, like PrimOps, and let CoreToStg do the let-to-case transformation.
188 But we don't do that because in the case of primops and functions strictness
189 is a *property* not a *requirement*. In the case of constructors we need to
190 do something active to evaluate the argument.
192 Making an explicit case expression allows the simplifier to eliminate
193 it in the (common) case where the constructor arg is already evaluated.
195 [Wrappers for data instance tycons]
196 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
197 In the case of data instances, the wrapper also applies the coercion turning
198 the representation type into the family instance type to cast the result of
199 the wrapper. For example, consider the declarations
201 data family Map k :: * -> *
202 data instance Map (a, b) v = MapPair (Map a (Pair b v))
204 The tycon to which the datacon MapPair belongs gets a unique internal name of
205 the form :R123Map, and we call it the representation tycon. In contrast, Map
206 is the family tycon (accessible via tyConFamInst_maybe). The wrapper and work
207 of MapPair get the types
209 $WMapPair :: forall a b v. Map a (Map a b v) -> Map (a, b) v
210 $wMapPair :: forall a b v. Map a (Map a b v) -> :R123Map a b v
212 which implies that the wrapper code will have to apply the coercion moving
213 between representation and family type. It is accessible via
214 tyConFamilyCoercion_maybe and has kind
216 Co123Map a b v :: {Map (a, b) v :=: :R123Map a b v}
218 This coercion is conditionally applied by wrapFamInstBody.
221 mkDataConIds :: Name -> Name -> DataCon -> DataConIds
222 mkDataConIds wrap_name wkr_name data_con
224 = DCIds Nothing nt_work_id -- Newtype, only has a worker
226 | any isMarkedStrict all_strict_marks -- Algebraic, needs wrapper
227 || not (null eq_spec) -- NB: LoadIface.ifaceDeclSubBndrs
228 || isFamInstTyCon tycon -- depends on this test
229 = DCIds (Just alg_wrap_id) wrk_id
231 | otherwise -- Algebraic, no wrapper
232 = DCIds Nothing wrk_id
234 (univ_tvs, ex_tvs, eq_spec,
235 theta, orig_arg_tys) = dataConFullSig data_con
236 tycon = dataConTyCon data_con
238 ----------- Wrapper --------------
239 -- We used to include the stupid theta in the wrapper's args
240 -- but now we don't. Instead the type checker just injects these
241 -- extra constraints where necessary.
242 wrap_tvs = (univ_tvs `minusList` map fst eq_spec) ++ ex_tvs
243 subst = mkTopTvSubst eq_spec
244 famSubst = ASSERT( length (tyConTyVars tycon ) ==
245 length (mkTyVarTys univ_tvs) )
246 zipTopTvSubst (tyConTyVars tycon) (mkTyVarTys univ_tvs)
247 -- substitution mapping the type constructor's type
248 -- arguments to the universals of the data constructor
249 -- (crucial when type checking interfaces)
250 dict_tys = mkPredTys theta
251 result_ty_args = map (substTyVar subst) univ_tvs
252 result_ty = case tyConFamInst_maybe tycon of
253 -- ordinary constructor
254 Nothing -> mkTyConApp tycon result_ty_args
255 -- family instance constructor
258 mkTyConApp familyTyCon ( substTys subst
261 wrap_ty = mkForAllTys wrap_tvs $ mkFunTys dict_tys $
262 mkFunTys orig_arg_tys $ result_ty
263 -- NB: watch out here if you allow user-written equality
264 -- constraints in data constructor signatures
266 ----------- Worker (algebraic data types only) --------------
267 -- The *worker* for the data constructor is the function that
268 -- takes the representation arguments and builds the constructor.
269 wrk_id = mkGlobalId (DataConWorkId data_con) wkr_name
270 (dataConRepType data_con) wkr_info
272 wkr_arity = dataConRepArity data_con
273 wkr_info = noCafIdInfo
274 `setArityInfo` wkr_arity
275 `setAllStrictnessInfo` Just wkr_sig
276 `setUnfoldingInfo` evaldUnfolding -- Record that it's evaluated,
279 wkr_sig = mkStrictSig (mkTopDmdType (replicate wkr_arity topDmd) cpr_info)
280 -- Notice that we do *not* say the worker is strict
281 -- even if the data constructor is declared strict
282 -- e.g. data T = MkT !(Int,Int)
283 -- Why? Because the *wrapper* is strict (and its unfolding has case
284 -- expresssions that do the evals) but the *worker* itself is not.
285 -- If we pretend it is strict then when we see
286 -- case x of y -> $wMkT y
287 -- the simplifier thinks that y is "sure to be evaluated" (because
288 -- $wMkT is strict) and drops the case. No, $wMkT is not strict.
290 -- When the simplifer sees a pattern
291 -- case e of MkT x -> ...
292 -- it uses the dataConRepStrictness of MkT to mark x as evaluated;
293 -- but that's fine... dataConRepStrictness comes from the data con
294 -- not from the worker Id.
296 cpr_info | isProductTyCon tycon &&
299 wkr_arity <= mAX_CPR_SIZE = retCPR
301 -- RetCPR is only true for products that are real data types;
302 -- that is, not unboxed tuples or [non-recursive] newtypes
304 ----------- Workers for newtypes --------------
305 nt_work_id = mkGlobalId (DataConWrapId data_con) wkr_name wrap_ty nt_work_info
306 nt_work_info = noCafIdInfo -- The NoCaf-ness is set by noCafIdInfo
307 `setArityInfo` 1 -- Arity 1
308 `setUnfoldingInfo` newtype_unf
309 newtype_unf = ASSERT( isVanillaDataCon data_con &&
310 isSingleton orig_arg_tys )
311 -- No existentials on a newtype, but it can have a context
312 -- e.g. newtype Eq a => T a = MkT (...)
313 mkCompulsoryUnfolding $
314 mkLams wrap_tvs $ Lam id_arg1 $
315 wrapNewTypeBody tycon result_ty_args
318 id_arg1 = mkTemplateLocal 1 (head orig_arg_tys)
320 ----------- Wrappers for algebraic data types --------------
321 alg_wrap_id = mkGlobalId (DataConWrapId data_con) wrap_name wrap_ty alg_wrap_info
322 alg_wrap_info = noCafIdInfo -- The NoCaf-ness is set by noCafIdInfo
323 `setArityInfo` alg_arity
324 -- It's important to specify the arity, so that partial
325 -- applications are treated as values
326 `setUnfoldingInfo` alg_unf
327 `setAllStrictnessInfo` Just wrap_sig
329 all_strict_marks = dataConExStricts data_con ++ dataConStrictMarks data_con
330 wrap_sig = mkStrictSig (mkTopDmdType arg_dmds cpr_info)
331 arg_dmds = map mk_dmd all_strict_marks
332 mk_dmd str | isMarkedStrict str = evalDmd
333 | otherwise = lazyDmd
334 -- The Cpr info can be important inside INLINE rhss, where the
335 -- wrapper constructor isn't inlined.
336 -- And the argument strictness can be important too; we
337 -- may not inline a contructor when it is partially applied.
339 -- data W = C !Int !Int !Int
340 -- ...(let w = C x in ...(w p q)...)...
341 -- we want to see that w is strict in its two arguments
343 alg_unf = mkTopUnfolding $ Note InlineMe $
345 mkLams dict_args $ mkLams id_args $
346 foldr mk_case con_app
347 (zip (dict_args ++ id_args) all_strict_marks)
350 con_app _ rep_ids = wrapFamInstBody tycon result_ty_args $
351 Var wrk_id `mkTyApps` result_ty_args
353 `mkTyApps` map snd eq_spec
354 `mkVarApps` reverse rep_ids
356 (dict_args,i2) = mkLocals 1 dict_tys
357 (id_args,i3) = mkLocals i2 orig_arg_tys
361 :: (Id, StrictnessMark) -- Arg, strictness
362 -> (Int -> [Id] -> CoreExpr) -- Body
363 -> Int -- Next rep arg id
364 -> [Id] -- Rep args so far, reversed
366 mk_case (arg,strict) body i rep_args
368 NotMarkedStrict -> body i (arg:rep_args)
370 | isUnLiftedType (idType arg) -> body i (arg:rep_args)
372 Case (Var arg) arg result_ty [(DEFAULT,[], body i (arg:rep_args))]
375 -> unboxProduct i (Var arg) (idType arg) the_body
377 the_body i con_args = body i (reverse con_args ++ rep_args)
379 mAX_CPR_SIZE :: Arity
381 -- We do not treat very big tuples as CPR-ish:
382 -- a) for a start we get into trouble because there aren't
383 -- "enough" unboxed tuple types (a tiresome restriction,
385 -- b) more importantly, big unboxed tuples get returned mainly
386 -- on the stack, and are often then allocated in the heap
387 -- by the caller. So doing CPR for them may in fact make
390 mkLocals i tys = (zipWith mkTemplateLocal [i..i+n-1] tys, i+n)
394 -- If the type constructor is a representation type of a data instance, wrap
395 -- the expression into a cast adjusting the expression type, which is an
396 -- instance of the representation type, to the corresponding instance of the
397 -- family instance type.
399 wrapFamInstBody :: TyCon -> [Type] -> CoreExpr -> CoreExpr
400 wrapFamInstBody tycon args result_expr
401 | Just co_con <- tyConFamilyCoercion_maybe tycon
402 = mkCoerce (mkSymCoercion (mkTyConApp co_con args)) result_expr
406 -- Apply the coercion in the opposite direction.
408 unwrapFamInstBody :: TyCon -> [Type] -> CoreExpr -> CoreExpr
409 unwrapFamInstBody tycon args result_expr
410 | Just co_con <- tyConFamilyCoercion_maybe tycon
411 = mkCoerce (mkTyConApp co_con args) result_expr
418 %************************************************************************
420 \subsection{Record selectors}
422 %************************************************************************
424 We're going to build a record selector unfolding that looks like this:
426 data T a b c = T1 { ..., op :: a, ...}
427 | T2 { ..., op :: a, ...}
430 sel = /\ a b c -> \ d -> case d of
435 Similarly for newtypes
437 newtype N a = MkN { unN :: a->a }
440 unN n = coerce (a->a) n
442 We need to take a little care if the field has a polymorphic type:
444 data R = R { f :: forall a. a->a }
448 f :: forall a. R -> a -> a
449 f = /\ a \ r = case r of
452 (not f :: R -> forall a. a->a, which gives the type inference mechanism
453 problems at call sites)
455 Similarly for (recursive) newtypes
457 newtype N = MkN { unN :: forall a. a->a }
459 unN :: forall b. N -> b -> b
460 unN = /\b -> \n:N -> (coerce (forall a. a->a) n)
463 Note [Naughty record selectors]
464 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
465 A "naughty" field is one for which we can't define a record
466 selector, because an existential type variable would escape. For example:
467 data T = forall a. MkT { x,y::a }
468 We obviously can't define
470 Nevertheless we *do* put a RecordSelId into the type environment
471 so that if the user tries to use 'x' as a selector we can bleat
472 helpfully, rather than saying unhelpfully that 'x' is not in scope.
473 Hence the sel_naughty flag, to identify record selectors that don't really exist.
475 In general, a field is naughty if its type mentions a type variable that
476 isn't in the result type of the constructor.
478 Note [GADT record selectors]
479 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
480 For GADTs, we require that all constructors with a common field 'f' have the same
481 result type (modulo alpha conversion). [Checked in TcTyClsDecls.checkValidTyCon]
484 T1 { f :: a } :: T [a]
485 T2 { f :: a, y :: b } :: T [a]
486 and now the selector takes that type as its argument:
487 f :: forall a. T [a] -> a
491 Note the forall'd tyvars of the selector are just the free tyvars
492 of the result type; there may be other tyvars in the constructor's
493 type (e.g. 'b' in T2).
497 -- Steps for handling "naughty" vs "non-naughty" selectors:
498 -- 1. Determine naughtiness by comparing field type vs result type
499 -- 2. Install naughty ones with selector_ty of type _|_ and fill in mzero for info
500 -- 3. If it's not naughty, do the normal plan.
502 mkRecordSelId :: TyCon -> FieldLabel -> Id
503 mkRecordSelId tycon field_label
504 -- Assumes that all fields with the same field label have the same type
505 | is_naughty = naughty_id
508 is_naughty = not (tyVarsOfType field_ty `subVarSet` res_tv_set)
509 sel_id_details = RecordSelId tycon field_label is_naughty
511 -- Escapist case here for naughty construcotrs
512 -- We give it no IdInfo, and a type of forall a.a (never looked at)
513 naughty_id = mkGlobalId sel_id_details field_label forall_a_a noCafIdInfo
514 forall_a_a = mkForAllTy alphaTyVar (mkTyVarTy alphaTyVar)
516 -- Normal case starts here
517 sel_id = mkGlobalId sel_id_details field_label selector_ty info
518 data_cons = tyConDataCons tycon
519 data_cons_w_field = filter has_field data_cons -- Can't be empty!
520 has_field con = field_label `elem` dataConFieldLabels con
522 con1 = head data_cons_w_field
523 res_tys = dataConResTys con1
524 res_tv_set = tyVarsOfTypes res_tys
525 res_tvs = varSetElems res_tv_set
526 data_ty = mkTyConApp tycon res_tys
527 field_ty = dataConFieldType con1 field_label
529 -- *Very* tiresomely, the selectors are (unnecessarily!) overloaded over
530 -- just the dictionaries in the types of the constructors that contain
531 -- the relevant field. [The Report says that pattern matching on a
532 -- constructor gives the same constraints as applying it.] Urgh.
534 -- However, not all data cons have all constraints (because of
535 -- BuildTyCl.mkDataConStupidTheta). So we need to find all the data cons
536 -- involved in the pattern match and take the union of their constraints.
537 stupid_dict_tys = mkPredTys (dataConsStupidTheta data_cons_w_field)
538 n_stupid_dicts = length stupid_dict_tys
540 (field_tyvars,pre_field_theta,field_tau) = tcSplitSigmaTy field_ty
542 field_theta = filter (not . isEqPred) pre_field_theta
543 field_dict_tys = mkPredTys field_theta
544 n_field_dict_tys = length field_dict_tys
545 -- If the field has a universally quantified type we have to
546 -- be a bit careful. Suppose we have
547 -- data R = R { op :: forall a. Foo a => a -> a }
548 -- Then we can't give op the type
549 -- op :: R -> forall a. Foo a => a -> a
550 -- because the typechecker doesn't understand foralls to the
551 -- right of an arrow. The "right" type to give it is
552 -- op :: forall a. Foo a => R -> a -> a
553 -- But then we must generate the right unfolding too:
554 -- op = /\a -> \dfoo -> \ r ->
557 -- Note that this is exactly the type we'd infer from a user defn
561 selector_ty = mkForAllTys res_tvs $ mkForAllTys field_tyvars $
562 mkFunTys stupid_dict_tys $ mkFunTys field_dict_tys $
563 mkFunTy data_ty field_tau
565 arity = 1 + n_stupid_dicts + n_field_dict_tys
567 (strict_sig, rhs_w_str) = dmdAnalTopRhs sel_rhs
568 -- Use the demand analyser to work out strictness.
569 -- With all this unpackery it's not easy!
572 `setCafInfo` caf_info
574 `setUnfoldingInfo` mkTopUnfolding rhs_w_str
575 `setAllStrictnessInfo` Just strict_sig
577 -- Allocate Ids. We do it a funny way round because field_dict_tys is
578 -- almost always empty. Also note that we use max_dict_tys
579 -- rather than n_dict_tys, because the latter gives an infinite loop:
580 -- n_dict tys depends on the_alts, which depens on arg_ids, which depends
581 -- on arity, which depends on n_dict tys. Sigh! Mega sigh!
582 stupid_dict_ids = mkTemplateLocalsNum 1 stupid_dict_tys
583 max_stupid_dicts = length (tyConStupidTheta tycon)
584 field_dict_base = max_stupid_dicts + 1
585 field_dict_ids = mkTemplateLocalsNum field_dict_base field_dict_tys
586 dict_id_base = field_dict_base + n_field_dict_tys
587 data_id = mkTemplateLocal dict_id_base data_ty
588 arg_base = dict_id_base + 1
590 the_alts :: [CoreAlt]
591 the_alts = map mk_alt data_cons_w_field -- Already sorted by data-con
592 no_default = length data_cons == length data_cons_w_field -- No default needed
594 default_alt | no_default = []
595 | otherwise = [(DEFAULT, [], error_expr)]
597 -- The default branch may have CAF refs, because it calls recSelError etc.
598 caf_info | no_default = NoCafRefs
599 | otherwise = MayHaveCafRefs
601 sel_rhs = mkLams res_tvs $ mkLams field_tyvars $
602 mkLams stupid_dict_ids $ mkLams field_dict_ids $
603 Lam data_id $ mk_result sel_body
605 -- NB: A newtype always has a vanilla DataCon; no existentials etc
606 -- res_tys will simply be the dataConUnivTyVars
607 sel_body | isNewTyCon tycon = unwrapNewTypeBody tycon res_tys (Var data_id)
608 | otherwise = Case (Var data_id) data_id field_ty (default_alt ++ the_alts)
610 mk_result poly_result = mkVarApps (mkVarApps poly_result field_tyvars) field_dict_ids
611 -- We pull the field lambdas to the top, so we need to
612 -- apply them in the body. For example:
613 -- data T = MkT { foo :: forall a. a->a }
615 -- foo :: forall a. T -> a -> a
616 -- foo = /\a. \t:T. case t of { MkT f -> f a }
619 = ASSERT2( res_ty `tcEqType` field_ty, ppr data_con $$ ppr res_ty $$ ppr field_ty )
620 mkReboxingAlt rebox_uniqs data_con (ex_tvs ++ co_tvs ++ arg_vs) rhs
622 -- get pattern binders with types appropriately instantiated
623 arg_uniqs = map mkBuiltinUnique [arg_base..]
624 (ex_tvs, co_tvs, arg_vs) = dataConOrigInstPat arg_uniqs data_con res_tys
626 rebox_base = arg_base + length ex_tvs + length co_tvs + length arg_vs
627 rebox_uniqs = map mkBuiltinUnique [rebox_base..]
629 -- data T :: *->* where T1 { fld :: Maybe b } -> T [b]
630 -- Hence T1 :: forall a b. (a=[b]) => b -> T a
631 -- fld :: forall b. T [b] -> Maybe b
632 -- fld = /\b.\(t:T[b]). case t of
633 -- T1 b' (c : [b]=[b']) (x:Maybe b')
634 -- -> x `cast` Maybe (sym (right c))
636 Succeeded refinement = gadtRefine emptyRefinement ex_tvs co_tvs
637 (co_fn, res_ty) = refineType refinement (idType the_arg_id)
638 -- Generate the refinement for b'=b,
639 -- and apply to (Maybe b'), to get (Maybe b)
642 WpCo co -> Cast (Var the_arg_id) co
643 id_co -> ASSERT(isIdHsWrapper id_co) Var the_arg_id
645 field_vs = filter (not . isPredTy . idType) arg_vs
646 the_arg_id = assoc "mkRecordSelId:mk_alt" (field_lbls `zip` field_vs) field_label
647 field_lbls = dataConFieldLabels data_con
649 error_expr = mkRuntimeErrorApp rEC_SEL_ERROR_ID field_ty full_msg
650 full_msg = showSDoc (sep [text "No match in record selector", ppr sel_id])
652 -- unbox a product type...
653 -- we will recurse into newtypes, casting along the way, and unbox at the
654 -- first product data constructor we find. e.g.
656 -- data PairInt = PairInt Int Int
657 -- newtype S = MkS PairInt
660 -- If we have e = MkT (MkS (PairInt 0 1)) and some body expecting a list of
661 -- ids, we get (modulo int passing)
663 -- case (e `cast` CoT) `cast` CoS of
664 -- PairInt a b -> body [a,b]
666 -- The Ints passed around are just for creating fresh locals
667 unboxProduct :: Int -> CoreExpr -> Type -> (Int -> [Id] -> CoreExpr) -> CoreExpr
668 unboxProduct i arg arg_ty body
671 result = mkUnpackCase the_id arg con_args boxing_con rhs
672 (_tycon, _tycon_args, boxing_con, tys) = deepSplitProductType "unboxProduct" arg_ty
673 ([the_id], i') = mkLocals i [arg_ty]
674 (con_args, i'') = mkLocals i' tys
675 rhs = body i'' con_args
677 mkUnpackCase :: Id -> CoreExpr -> [Id] -> DataCon -> CoreExpr -> CoreExpr
678 -- (mkUnpackCase x e args Con body)
680 -- case (e `cast` ...) of bndr { Con args -> body }
682 -- the type of the bndr passed in is irrelevent
683 mkUnpackCase bndr arg unpk_args boxing_con body
684 = Case cast_arg (setIdType bndr bndr_ty) (exprType body) [(DataAlt boxing_con, unpk_args, body)]
686 (cast_arg, bndr_ty) = go (idType bndr) arg
688 | (tycon, tycon_args, _, _) <- splitProductType "mkUnpackCase" ty
689 , isNewTyCon tycon && not (isRecursiveTyCon tycon)
690 = go (newTyConInstRhs tycon tycon_args)
691 (unwrapNewTypeBody tycon tycon_args arg)
692 | otherwise = (arg, ty)
695 reboxProduct :: [Unique] -- uniques to create new local binders
696 -> Type -- type of product to box
697 -> ([Unique], -- remaining uniques
698 CoreExpr, -- boxed product
699 [Id]) -- Ids being boxed into product
702 (_tycon, _tycon_args, _pack_con, con_arg_tys) = deepSplitProductType "reboxProduct" ty
704 us' = dropList con_arg_tys us
706 arg_ids = zipWith (mkSysLocal FSLIT("rb")) us con_arg_tys
708 bind_rhs = mkProductBox arg_ids ty
711 (us', bind_rhs, arg_ids)
713 mkProductBox :: [Id] -> Type -> CoreExpr
714 mkProductBox arg_ids ty
717 (tycon, tycon_args, pack_con, _con_arg_tys) = splitProductType "mkProductBox" ty
720 | isNewTyCon tycon && not (isRecursiveTyCon tycon)
721 = wrap (mkProductBox arg_ids (newTyConInstRhs tycon tycon_args))
722 | otherwise = mkConApp pack_con (map Type tycon_args ++ map Var arg_ids)
724 wrap expr = wrapNewTypeBody tycon tycon_args expr
727 -- (mkReboxingAlt us con xs rhs) basically constructs the case
728 -- alternative (con, xs, rhs)
729 -- but it does the reboxing necessary to construct the *source*
730 -- arguments, xs, from the representation arguments ys.
732 -- data T = MkT !(Int,Int) Bool
734 -- mkReboxingAlt MkT [x,b] r
735 -- = (DataAlt MkT, [y::Int,z::Int,b], let x = (y,z) in r)
737 -- mkDataAlt should really be in DataCon, but it can't because
738 -- it manipulates CoreSyn.
741 :: [Unique] -- Uniques for the new Ids
743 -> [Var] -- Source-level args, including existential dicts
747 mkReboxingAlt us con args rhs
748 | not (any isMarkedUnboxed stricts)
749 = (DataAlt con, args, rhs)
753 (binds, args') = go args stricts us
755 (DataAlt con, args', mkLets binds rhs)
758 stricts = dataConExStricts con ++ dataConStrictMarks con
760 go [] _stricts _us = ([], [])
762 -- Type variable case
763 go (arg:args) stricts us
765 = let (binds, args') = go args stricts us
766 in (binds, arg:args')
768 -- Term variable case
769 go (arg:args) (str:stricts) us
770 | isMarkedUnboxed str
772 let (binds, unpacked_args') = go args stricts us'
773 (us', bind_rhs, unpacked_args) = reboxProduct us (idType arg)
775 (NonRec arg bind_rhs : binds, unpacked_args ++ unpacked_args')
777 = let (binds, args') = go args stricts us
778 in (binds, arg:args')
782 %************************************************************************
784 \subsection{Dictionary selectors}
786 %************************************************************************
788 Selecting a field for a dictionary. If there is just one field, then
789 there's nothing to do.
791 Dictionary selectors may get nested forall-types. Thus:
794 op :: forall b. Ord b => a -> b -> b
796 Then the top-level type for op is
798 op :: forall a. Foo a =>
802 This is unlike ordinary record selectors, which have all the for-alls
803 at the outside. When dealing with classes it's very convenient to
804 recover the original type signature from the class op selector.
807 mkDictSelId :: Name -> Class -> Id
808 mkDictSelId name clas
809 = mkGlobalId (ClassOpId clas) name sel_ty info
811 sel_ty = mkForAllTys tyvars (mkFunTy (idType dict_id) (idType the_arg_id))
812 -- We can't just say (exprType rhs), because that would give a type
814 -- for a single-op class (after all, the selector is the identity)
815 -- But it's type must expose the representation of the dictionary
816 -- to gat (say) C a -> (a -> a)
820 `setUnfoldingInfo` mkTopUnfolding rhs
821 `setAllStrictnessInfo` Just strict_sig
823 -- We no longer use 'must-inline' on record selectors. They'll
824 -- inline like crazy if they scrutinise a constructor
826 -- The strictness signature is of the form U(AAAVAAAA) -> T
827 -- where the V depends on which item we are selecting
828 -- It's worth giving one, so that absence info etc is generated
829 -- even if the selector isn't inlined
830 strict_sig = mkStrictSig (mkTopDmdType [arg_dmd] TopRes)
831 arg_dmd | isNewTyCon tycon = evalDmd
832 | otherwise = Eval (Prod [ if the_arg_id == id then evalDmd else Abs
835 tycon = classTyCon clas
836 [data_con] = tyConDataCons tycon
837 tyvars = dataConUnivTyVars data_con
838 arg_tys = ASSERT( isVanillaDataCon data_con ) dataConRepArgTys data_con
839 the_arg_id = assoc "MkId.mkDictSelId" (map idName (classSelIds clas) `zip` arg_ids) name
841 pred = mkClassPred clas (mkTyVarTys tyvars)
842 (dict_id:arg_ids) = mkTemplateLocals (mkPredTy pred : arg_tys)
844 rhs = mkLams tyvars (Lam dict_id rhs_body)
845 rhs_body | isNewTyCon tycon = unwrapNewTypeBody tycon (map mkTyVarTy tyvars) (Var dict_id)
846 | otherwise = Case (Var dict_id) dict_id (idType the_arg_id)
847 [(DataAlt data_con, arg_ids, Var the_arg_id)]
849 wrapNewTypeBody :: TyCon -> [Type] -> CoreExpr -> CoreExpr
850 -- The wrapper for the data constructor for a newtype looks like this:
851 -- newtype T a = MkT (a,Int)
852 -- MkT :: forall a. (a,Int) -> T a
853 -- MkT = /\a. \(x:(a,Int)). x `cast` sym (CoT a)
854 -- where CoT is the coercion TyCon assoicated with the newtype
856 -- The call (wrapNewTypeBody T [a] e) returns the
857 -- body of the wrapper, namely
858 -- e `cast` (CoT [a])
860 -- If a coercion constructor is prodivided in the newtype, then we use
861 -- it, otherwise the wrap/unwrap are both no-ops
863 -- If the we are dealing with a newtype instance, we have a second coercion
864 -- identifying the family instance with the constructor of the newtype
865 -- instance. This coercion is applied in any case (ie, composed with the
866 -- coercion constructor of the newtype or applied by itself).
868 wrapNewTypeBody tycon args result_expr
869 = wrapFamInstBody tycon args inner
872 | Just co_con <- newTyConCo_maybe tycon
873 = mkCoerce (mkSymCoercion (mkTyConApp co_con args)) result_expr
877 -- When unwrapping, we do *not* apply any family coercion, because this will
878 -- be done via a CoPat by the type checker. We have to do it this way as
879 -- computing the right type arguments for the coercion requires more than just
880 -- a spliting operation (cf, TcPat.tcConPat).
882 unwrapNewTypeBody :: TyCon -> [Type] -> CoreExpr -> CoreExpr
883 unwrapNewTypeBody tycon args result_expr
884 | Just co_con <- newTyConCo_maybe tycon
885 = mkCoerce (mkTyConApp co_con args) result_expr
893 %************************************************************************
895 \subsection{Primitive operations
897 %************************************************************************
900 mkPrimOpId :: PrimOp -> Id
904 (tyvars,arg_tys,res_ty, arity, strict_sig) = primOpSig prim_op
905 ty = mkForAllTys tyvars (mkFunTys arg_tys res_ty)
906 name = mkWiredInName gHC_PRIM (primOpOcc prim_op)
907 (mkPrimOpIdUnique (primOpTag prim_op))
908 Nothing (AnId id) UserSyntax
909 id = mkGlobalId (PrimOpId prim_op) name ty info
912 `setSpecInfo` mkSpecInfo (primOpRules prim_op name)
914 `setAllStrictnessInfo` Just strict_sig
916 -- For each ccall we manufacture a separate CCallOpId, giving it
917 -- a fresh unique, a type that is correct for this particular ccall,
918 -- and a CCall structure that gives the correct details about calling
921 -- The *name* of this Id is a local name whose OccName gives the full
922 -- details of the ccall, type and all. This means that the interface
923 -- file reader can reconstruct a suitable Id
925 mkFCallId :: Unique -> ForeignCall -> Type -> Id
926 mkFCallId uniq fcall ty
927 = ASSERT( isEmptyVarSet (tyVarsOfType ty) )
928 -- A CCallOpId should have no free type variables;
929 -- when doing substitutions won't substitute over it
930 mkGlobalId (FCallId fcall) name ty info
932 occ_str = showSDoc (braces (ppr fcall <+> ppr ty))
933 -- The "occurrence name" of a ccall is the full info about the
934 -- ccall; it is encoded, but may have embedded spaces etc!
936 name = mkFCallName uniq occ_str
940 `setAllStrictnessInfo` Just strict_sig
942 (_, tau) = tcSplitForAllTys ty
943 (arg_tys, _) = tcSplitFunTys tau
944 arity = length arg_tys
945 strict_sig = mkStrictSig (mkTopDmdType (replicate arity evalDmd) TopRes)
949 %************************************************************************
951 \subsection{DictFuns and default methods}
953 %************************************************************************
955 Important notes about dict funs and default methods
956 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
957 Dict funs and default methods are *not* ImplicitIds. Their definition
958 involves user-written code, so we can't figure out their strictness etc
959 based on fixed info, as we can for constructors and record selectors (say).
961 We build them as LocalIds, but with External Names. This ensures that
962 they are taken to account by free-variable finding and dependency
963 analysis (e.g. CoreFVs.exprFreeVars).
965 Why shouldn't they be bound as GlobalIds? Because, in particular, if
966 they are globals, the specialiser floats dict uses above their defns,
967 which prevents good simplifications happening. Also the strictness
968 analyser treats a occurrence of a GlobalId as imported and assumes it
969 contains strictness in its IdInfo, which isn't true if the thing is
970 bound in the same module as the occurrence.
972 It's OK for dfuns to be LocalIds, because we form the instance-env to
973 pass on to the next module (md_insts) in CoreTidy, afer tidying
974 and globalising the top-level Ids.
976 BUT make sure they are *exported* LocalIds (mkExportedLocalId) so
977 that they aren't discarded by the occurrence analyser.
980 mkDefaultMethodId dm_name ty = mkExportedLocalId dm_name ty
982 mkDictFunId :: Name -- Name to use for the dict fun;
989 mkDictFunId dfun_name inst_tyvars dfun_theta clas inst_tys
990 = mkExportedLocalId dfun_name dfun_ty
992 dfun_ty = mkSigmaTy inst_tyvars dfun_theta (mkDictTy clas inst_tys)
994 {- 1 dec 99: disable the Mark Jones optimisation for the sake
995 of compatibility with Hugs.
996 See `types/InstEnv' for a discussion related to this.
998 (class_tyvars, sc_theta, _, _) = classBigSig clas
999 not_const (clas, tys) = not (isEmptyVarSet (tyVarsOfTypes tys))
1000 sc_theta' = substClasses (zipTopTvSubst class_tyvars inst_tys) sc_theta
1001 dfun_theta = case inst_decl_theta of
1002 [] -> [] -- If inst_decl_theta is empty, then we don't
1003 -- want to have any dict arguments, so that we can
1004 -- expose the constant methods.
1006 other -> nub (inst_decl_theta ++ filter not_const sc_theta')
1007 -- Otherwise we pass the superclass dictionaries to
1008 -- the dictionary function; the Mark Jones optimisation.
1010 -- NOTE the "nub". I got caught by this one:
1011 -- class Monad m => MonadT t m where ...
1012 -- instance Monad m => MonadT (EnvT env) m where ...
1013 -- Here, the inst_decl_theta has (Monad m); but so
1014 -- does the sc_theta'!
1016 -- NOTE the "not_const". I got caught by this one too:
1017 -- class Foo a => Baz a b where ...
1018 -- instance Wob b => Baz T b where..
1019 -- Now sc_theta' has Foo T
1024 %************************************************************************
1026 \subsection{Un-definable}
1028 %************************************************************************
1030 These Ids can't be defined in Haskell. They could be defined in
1031 unfoldings in the wired-in GHC.Prim interface file, but we'd have to
1032 ensure that they were definitely, definitely inlined, because there is
1033 no curried identifier for them. That's what mkCompulsoryUnfolding
1034 does. If we had a way to get a compulsory unfolding from an interface
1035 file, we could do that, but we don't right now.
1037 unsafeCoerce# isn't so much a PrimOp as a phantom identifier, that
1038 just gets expanded into a type coercion wherever it occurs. Hence we
1039 add it as a built-in Id with an unfolding here.
1041 The type variables we use here are "open" type variables: this means
1042 they can unify with both unlifted and lifted types. Hence we provide
1043 another gun with which to shoot yourself in the foot.
1046 mkWiredInIdName mod fs uniq id
1047 = mkWiredInName mod (mkOccNameFS varName fs) uniq Nothing (AnId id) UserSyntax
1049 unsafeCoerceName = mkWiredInIdName gHC_PRIM FSLIT("unsafeCoerce#") unsafeCoerceIdKey unsafeCoerceId
1050 nullAddrName = mkWiredInIdName gHC_PRIM FSLIT("nullAddr#") nullAddrIdKey nullAddrId
1051 seqName = mkWiredInIdName gHC_PRIM FSLIT("seq") seqIdKey seqId
1052 realWorldName = mkWiredInIdName gHC_PRIM FSLIT("realWorld#") realWorldPrimIdKey realWorldPrimId
1053 lazyIdName = mkWiredInIdName gHC_BASE FSLIT("lazy") lazyIdKey lazyId
1055 errorName = mkWiredInIdName gHC_ERR FSLIT("error") errorIdKey eRROR_ID
1056 recSelErrorName = mkWiredInIdName gHC_ERR FSLIT("recSelError") recSelErrorIdKey rEC_SEL_ERROR_ID
1057 runtimeErrorName = mkWiredInIdName gHC_ERR FSLIT("runtimeError") runtimeErrorIdKey rUNTIME_ERROR_ID
1058 irrefutPatErrorName = mkWiredInIdName gHC_ERR FSLIT("irrefutPatError") irrefutPatErrorIdKey iRREFUT_PAT_ERROR_ID
1059 recConErrorName = mkWiredInIdName gHC_ERR FSLIT("recConError") recConErrorIdKey rEC_CON_ERROR_ID
1060 patErrorName = mkWiredInIdName gHC_ERR FSLIT("patError") patErrorIdKey pAT_ERROR_ID
1061 noMethodBindingErrorName = mkWiredInIdName gHC_ERR FSLIT("noMethodBindingError")
1062 noMethodBindingErrorIdKey nO_METHOD_BINDING_ERROR_ID
1063 nonExhaustiveGuardsErrorName
1064 = mkWiredInIdName gHC_ERR FSLIT("nonExhaustiveGuardsError")
1065 nonExhaustiveGuardsErrorIdKey nON_EXHAUSTIVE_GUARDS_ERROR_ID
1069 -- unsafeCoerce# :: forall a b. a -> b
1071 = pcMiscPrelId unsafeCoerceName ty info
1073 info = noCafIdInfo `setUnfoldingInfo` mkCompulsoryUnfolding rhs
1076 ty = mkForAllTys [openAlphaTyVar,openBetaTyVar]
1077 (mkFunTy openAlphaTy openBetaTy)
1078 [x] = mkTemplateLocals [openAlphaTy]
1079 rhs = mkLams [openAlphaTyVar,openBetaTyVar,x] $
1080 -- Note (Coerce openBetaTy openAlphaTy) (Var x)
1081 Cast (Var x) (mkUnsafeCoercion openAlphaTy openBetaTy)
1083 -- nullAddr# :: Addr#
1084 -- The reason is is here is because we don't provide
1085 -- a way to write this literal in Haskell.
1087 = pcMiscPrelId nullAddrName addrPrimTy info
1089 info = noCafIdInfo `setUnfoldingInfo`
1090 mkCompulsoryUnfolding (Lit nullAddrLit)
1093 = pcMiscPrelId seqName ty info
1095 info = noCafIdInfo `setUnfoldingInfo` mkCompulsoryUnfolding rhs
1098 ty = mkForAllTys [alphaTyVar,openBetaTyVar]
1099 (mkFunTy alphaTy (mkFunTy openBetaTy openBetaTy))
1100 [x,y] = mkTemplateLocals [alphaTy, openBetaTy]
1101 rhs = mkLams [alphaTyVar,openBetaTyVar,x,y] (Case (Var x) x openBetaTy [(DEFAULT, [], Var y)])
1103 -- lazy :: forall a?. a? -> a? (i.e. works for unboxed types too)
1104 -- Used to lazify pseq: pseq a b = a `seq` lazy b
1106 -- Also, no strictness: by being a built-in Id, all the info about lazyId comes from here,
1107 -- not from GHC.Base.hi. This is important, because the strictness
1108 -- analyser will spot it as strict!
1110 -- Also no unfolding in lazyId: it gets "inlined" by a HACK in the worker/wrapper pass
1111 -- (see WorkWrap.wwExpr)
1112 -- We could use inline phases to do this, but that would be vulnerable to changes in
1113 -- phase numbering....we must inline precisely after strictness analysis.
1115 = pcMiscPrelId lazyIdName ty info
1118 ty = mkForAllTys [alphaTyVar] (mkFunTy alphaTy alphaTy)
1120 lazyIdUnfolding :: CoreExpr -- Used to expand 'lazyId' after strictness anal
1121 lazyIdUnfolding = mkLams [openAlphaTyVar,x] (Var x)
1123 [x] = mkTemplateLocals [openAlphaTy]
1126 @realWorld#@ used to be a magic literal, \tr{void#}. If things get
1127 nasty as-is, change it back to a literal (@Literal@).
1129 voidArgId is a Local Id used simply as an argument in functions
1130 where we just want an arg to avoid having a thunk of unlifted type.
1132 x = \ void :: State# RealWorld -> (# p, q #)
1134 This comes up in strictness analysis
1137 realWorldPrimId -- :: State# RealWorld
1138 = pcMiscPrelId realWorldName realWorldStatePrimTy
1139 (noCafIdInfo `setUnfoldingInfo` evaldUnfolding)
1140 -- The evaldUnfolding makes it look that realWorld# is evaluated
1141 -- which in turn makes Simplify.interestingArg return True,
1142 -- which in turn makes INLINE things applied to realWorld# likely
1145 voidArgId -- :: State# RealWorld
1146 = mkSysLocal FSLIT("void") voidArgIdKey realWorldStatePrimTy
1150 %************************************************************************
1152 \subsection[PrelVals-error-related]{@error@ and friends; @trace@}
1154 %************************************************************************
1156 GHC randomly injects these into the code.
1158 @patError@ is just a version of @error@ for pattern-matching
1159 failures. It knows various ``codes'' which expand to longer
1160 strings---this saves space!
1162 @absentErr@ is a thing we put in for ``absent'' arguments. They jolly
1163 well shouldn't be yanked on, but if one is, then you will get a
1164 friendly message from @absentErr@ (rather than a totally random
1167 @parError@ is a special version of @error@ which the compiler does
1168 not know to be a bottoming Id. It is used in the @_par_@ and @_seq_@
1169 templates, but we don't ever expect to generate code for it.
1173 :: Id -- Should be of type (forall a. Addr# -> a)
1174 -- where Addr# points to a UTF8 encoded string
1175 -> Type -- The type to instantiate 'a'
1176 -> String -- The string to print
1179 mkRuntimeErrorApp err_id res_ty err_msg
1180 = mkApps (Var err_id) [Type res_ty, err_string]
1182 err_string = Lit (mkStringLit err_msg)
1184 rEC_SEL_ERROR_ID = mkRuntimeErrorId recSelErrorName
1185 rUNTIME_ERROR_ID = mkRuntimeErrorId runtimeErrorName
1186 iRREFUT_PAT_ERROR_ID = mkRuntimeErrorId irrefutPatErrorName
1187 rEC_CON_ERROR_ID = mkRuntimeErrorId recConErrorName
1188 pAT_ERROR_ID = mkRuntimeErrorId patErrorName
1189 nO_METHOD_BINDING_ERROR_ID = mkRuntimeErrorId noMethodBindingErrorName
1190 nON_EXHAUSTIVE_GUARDS_ERROR_ID = mkRuntimeErrorId nonExhaustiveGuardsErrorName
1192 -- The runtime error Ids take a UTF8-encoded string as argument
1193 mkRuntimeErrorId name = pc_bottoming_Id name runtimeErrorTy
1194 runtimeErrorTy = mkSigmaTy [openAlphaTyVar] [] (mkFunTy addrPrimTy openAlphaTy)
1198 eRROR_ID = pc_bottoming_Id errorName errorTy
1201 errorTy = mkSigmaTy [openAlphaTyVar] [] (mkFunTys [mkListTy charTy] openAlphaTy)
1202 -- Notice the openAlphaTyVar. It says that "error" can be applied
1203 -- to unboxed as well as boxed types. This is OK because it never
1204 -- returns, so the return type is irrelevant.
1208 %************************************************************************
1210 \subsection{Utilities}
1212 %************************************************************************
1215 pcMiscPrelId :: Name -> Type -> IdInfo -> Id
1216 pcMiscPrelId name ty info
1217 = mkVanillaGlobal name ty info
1218 -- We lie and say the thing is imported; otherwise, we get into
1219 -- a mess with dependency analysis; e.g., core2stg may heave in
1220 -- random calls to GHCbase.unpackPS__. If GHCbase is the module
1221 -- being compiled, then it's just a matter of luck if the definition
1222 -- will be in "the right place" to be in scope.
1224 pc_bottoming_Id name ty
1225 = pcMiscPrelId name ty bottoming_info
1227 bottoming_info = vanillaIdInfo `setAllStrictnessInfo` Just strict_sig
1228 -- Do *not* mark them as NoCafRefs, because they can indeed have
1229 -- CAF refs. For example, pAT_ERROR_ID calls GHC.Err.untangle,
1230 -- which has some CAFs
1231 -- In due course we may arrange that these error-y things are
1232 -- regarded by the GC as permanently live, in which case we
1233 -- can give them NoCaf info. As it is, any function that calls
1234 -- any pc_bottoming_Id will itself have CafRefs, which bloats
1237 strict_sig = mkStrictSig (mkTopDmdType [evalDmd] BotRes)
1238 -- These "bottom" out, no matter what their arguments
1240 (openAlphaTyVar:openBetaTyVar:_) = openAlphaTyVars
1241 openAlphaTy = mkTyVarTy openAlphaTyVar
1242 openBetaTy = mkTyVarTy openBetaTyVar