2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
4 \section[PrelVals]{Prelude values the compiler ``knows about''}
7 #include "HsVersions.h"
12 #if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ <= 201
13 IMPORT_DELOOPER(IdLoop) ( UnfoldingGuidance(..), mkUnfolding, nullSpecEnv, SpecEnv )
15 import {-# SOURCE #-} CoreUnfold ( UnfoldingGuidance(..), mkUnfolding )
16 import {-# SOURCE #-} SpecEnv ( SpecEnv, nullSpecEnv )
19 #if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ <= 201
20 IMPORT_DELOOPER(PrelLoop)
23 import Id ( SYN_IE(Id), GenId, mkImported, mkTemplateLocals )
31 import CmdLineOpts ( maybe_CompilingGhcInternals )
32 import CoreSyn -- quite a bit
33 import IdInfo -- quite a bit
34 import Literal ( mkMachInt )
35 import Name ( mkWiredInIdName, SYN_IE(Module) )
37 import PrimOp ( PrimOp(..) )
38 #if __GLASGOW_HASKELL__ >= 202
41 import Type ( mkTyVarTy )
43 import TyVar ( openAlphaTyVar, alphaTyVar, betaTyVar, gammaTyVar, SYN_IE(TyVar) )
44 import Unique -- lots of *Keys
51 mk_inline_unfolding = mkUnfolding IWantToBeINLINEd
53 pcMiscPrelId :: Unique{-IdKey-} -> Module -> FAST_STRING -> Type -> IdInfo -> Id
55 pcMiscPrelId key mod occ ty info
57 name = mkWiredInIdName key mod occ imp
58 imp = mkImported name ty info -- the usual case...
61 -- We lie and say the thing is imported; otherwise, we get into
62 -- a mess with dependency analysis; e.g., core2stg may heave in
63 -- random calls to GHCbase.unpackPS__. If GHCbase is the module
64 -- being compiled, then it's just a matter of luck if the definition
65 -- will be in "the right place" to be in scope.
68 %************************************************************************
70 \subsection[PrelVals-error-related]{@error@ and friends; @trace@}
72 %************************************************************************
74 GHC randomly injects these into the code.
76 @patError@ is just a version of @error@ for pattern-matching
77 failures. It knows various ``codes'' which expand to longer
78 strings---this saves space!
80 @absentErr@ is a thing we put in for ``absent'' arguments. They jolly
81 well shouldn't be yanked on, but if one is, then you will get a
82 friendly message from @absentErr@ (rather a totally random crash).
84 @parError@ is a special version of @error@ which the compiler does
85 not know to be a bottoming Id. It is used in the @_par_@ and @_seq_@
86 templates, but we don't ever expect to generate code for it.
89 pc_bottoming_Id key mod name ty
90 = pcMiscPrelId key mod name ty bottoming_info
92 bottoming_info = noIdInfo `addStrictnessInfo` mkBottomStrictnessInfo
93 -- these "bottom" out, no matter what their arguments
96 = pc_bottoming_Id errorIdKey eRROR SLIT("error") errorTy
99 = pc_bottoming_Id u gHC_ERR n errorTy
102 = generic_ERROR_ID patErrorIdKey SLIT("patError")
104 = generic_ERROR_ID recConErrorIdKey SLIT("recConError")
106 = generic_ERROR_ID recUpdErrorIdKey SLIT("recUpdError")
108 = generic_ERROR_ID irrefutPatErrorIdKey SLIT("irrefutPatError")
109 nON_EXHAUSTIVE_GUARDS_ERROR_ID
110 = generic_ERROR_ID nonExhaustiveGuardsErrorIdKey SLIT("nonExhaustiveGuardsError")
111 nO_DEFAULT_METHOD_ERROR_ID
112 = generic_ERROR_ID noDefaultMethodErrorIdKey SLIT("noDefaultMethodError")
113 nO_EXPLICIT_METHOD_ERROR_ID
114 = generic_ERROR_ID nonExplicitMethodErrorIdKey SLIT("noExplicitMethodError")
117 = pc_bottoming_Id absentErrorIdKey gHC_ERR SLIT("absentErr")
118 (mkSigmaTy [openAlphaTyVar] [] openAlphaTy)
121 = pcMiscPrelId parErrorIdKey gHC_ERR SLIT("parError")
122 (mkSigmaTy [openAlphaTyVar] [] openAlphaTy) noIdInfo
124 openAlphaTy = mkTyVarTy openAlphaTyVar
127 errorTy = mkSigmaTy [openAlphaTyVar] [] (mkFunTys [mkListTy charTy] openAlphaTy)
128 -- Notice the openAlphaTyVar. It says that "error" can be applied
129 -- to unboxed as well as boxed types. This is OK because it never
130 -- returns, so the return type is irrelevant.
133 We want \tr{GHCbase.trace} to be wired in
134 because we don't want the strictness analyser to get ahold of it,
135 decide that the second argument is strict, evaluate that first (!!),
136 and make a jolly old mess.
139 = pcMiscPrelId traceIdKey iO_BASE SLIT("trace") traceTy
140 (noIdInfo `addSpecInfo` pcGenerateSpecs traceIdKey tRACE_ID noIdInfo traceTy)
142 traceTy = mkSigmaTy [alphaTyVar] [] (mkFunTys [mkListTy charTy, alphaTy] alphaTy)
145 %************************************************************************
147 \subsection[PrelVals-Integer-support]{To support @Integer@ and @String@ literals}
149 %************************************************************************
153 = pcMiscPrelId packCStringIdKey{-ToDo:rename-} pACKED_STRING SLIT("packCString#")
154 (mkFunTys [stringTy] byteArrayPrimTy) noIdInfo
156 --------------------------------------------------------------------
159 = pcMiscPrelId unpackCStringIdKey pACKED_STRING SLIT("unpackCString#")
160 (mkFunTys [addrPrimTy{-a char *-}] stringTy) noIdInfo
162 -- (FunTy addrPrimTy{-a char *-} stringTy) (noIdInfo `addInfo` exactArity 1)
163 -- but I don't like wired-in IdInfos (WDP)
165 unpackCString2Id -- for cases when a string has a NUL in it
166 = pcMiscPrelId unpackCString2IdKey pACKED_STRING SLIT("unpackNBytes#")
167 (mkFunTys [addrPrimTy{-a char *-}, intPrimTy{-length-}] stringTy)
170 --------------------------------------------------------------------
171 unpackCStringAppendId
172 = pcMiscPrelId unpackCStringAppendIdKey pACKED_STRING SLIT("unpackAppendCString#")
173 (mkFunTys [addrPrimTy{-a "char *" pointer-},stringTy] stringTy)
175 {-LATER:`addUnfoldInfo` mkMagicUnfolding unpackCStringAppendIdKey-})
176 `addArityInfo` exactArity 2)
179 = pcMiscPrelId unpackCStringFoldrIdKey pACKED_STRING SLIT("unpackFoldrCString#")
180 (mkSigmaTy [alphaTyVar] []
181 (mkFunTys [addrPrimTy{-a "char *" pointer-},
182 mkFunTys [charTy, alphaTy] alphaTy,
186 {-LATER:`addUnfoldInfo` mkMagicUnfolding unpackCStringFoldrIdKey-})
187 `addArityInfo` exactArity 3)
190 OK, this is Will's idea: we should have magic values for Integers 0,
191 +1, +2, and -1 (go ahead, fire me):
195 = pcMiscPrelId integerZeroIdKey pREL_NUM SLIT("integer_0") integerTy noIdInfo
197 = pcMiscPrelId integerPlusOneIdKey pREL_NUM SLIT("integer_1") integerTy noIdInfo
199 = pcMiscPrelId integerPlusTwoIdKey pREL_NUM SLIT("integer_2") integerTy noIdInfo
201 = pcMiscPrelId integerMinusOneIdKey pREL_NUM SLIT("integer_m1") integerTy noIdInfo
204 %************************************************************************
206 \subsection[PrelVals-parallel]{@seq@ and @par@: for parallel operation (only)}
208 %************************************************************************
212 --------------------------------------------------------------------
213 -- seqId :: "seq", used w/ GRIP, etc., is really quite similar to
217 seq = /\ a b -> \ x y -> case x of { _ -> y }
220 seq = /\ a b -> \ x y -> case seq# x y of { _Lift y' -> y' }
223 seq = /\ a b -> \ x::a y::b -> case seq# x of { 0# -> parError#; _ -> y; }
227 seqId = pcMiscPrelId seqIdKey pRELUDE SLIT("seq")
228 (mkSigmaTy [alphaTyVar, betaTyVar] []
229 (mkFunTys [alphaTy, betaTy] betaTy))
230 (noIdInfo `addUnfoldInfo` (mk_inline_unfolding seq_template))
240 = mkLam [alphaTyVar, betaTyVar] [x, y] (
241 Case (Prim SeqOp [TyArg alphaTy, VarArg x]) (
243 [(mkMachInt 0, mkTyApp (Var pAR_ERROR_ID) [betaTy])]
244 (BindDefault z (Var y))))
246 --------------------------------------------------------------------
247 -- parId :: "par", also used w/ GRIP, etc.
251 par = /\ a b -> \ x y -> case (par# (case x of { _ -> () })) of { _ -> y }
255 par = /\ a b -> \ x y -> case par# x y of { _Lift y' -> y' }
259 par = /\ a b -> \ x::a y::b -> case par# x of { 0# -> parError#; _ -> y; }
262 parId = pcMiscPrelId parIdKey cONC_BASE SLIT("par")
263 (mkSigmaTy [alphaTyVar, betaTyVar] []
264 (mkFunTys [alphaTy, betaTy] betaTy))
265 (noIdInfo `addUnfoldInfo` (mk_inline_unfolding par_template))
275 = mkLam [alphaTyVar, betaTyVar] [x, y] (
276 Case (Prim ParOp [TyArg alphaTy, VarArg x]) (
278 [(mkMachInt 0, mkTyApp (Var pAR_ERROR_ID) [betaTy])]
279 (BindDefault z (Var y))))
281 -- forkId :: "fork", for *required* concurrent threads
283 _fork_ = /\ a b -> \ x::a y::b -> case fork# x of { 0# -> parError#; _ -> y; }
285 forkId = pcMiscPrelId forkIdKey cONC_BASE SLIT("fork")
286 (mkSigmaTy [alphaTyVar, betaTyVar] []
287 (mkFunTys [alphaTy, betaTy] betaTy))
288 (noIdInfo `addUnfoldInfo` (mk_inline_unfolding fork_template))
298 = mkLam [alphaTyVar, betaTyVar] [x, y] (
299 Case (Prim ForkOp [TyArg alphaTy, VarArg x]) (
301 [(mkMachInt 0, mkTyApp (Var pAR_ERROR_ID) [betaTy])]
302 (BindDefault z (Var y))))
309 parLocalId = pcMiscPrelId parLocalIdKey cONC_BASE SLIT("parLocal")
310 (mkSigmaTy [alphaTyVar, betaTyVar] []
311 (mkFunTys [intPrimTy, intPrimTy, intPrimTy, intPrimTy, alphaTy, betaTy] betaTy))
312 (noIdInfo `addUnfoldInfo` (mk_inline_unfolding parLocal_template))
314 -- Annotations: w: name, g: gran. info, s: size info, p: par info -- HWL
315 [w, g, s, p, x, y, z]
327 = mkLam [alphaTyVar, betaTyVar] [w, g, s, p, x, y] (
328 Case (Prim ParLocalOp [TyArg alphaTy, TyArg betaTy, VarArg x, VarArg w, VarArg g, VarArg s, VarArg p, VarArg y]) (
330 [(mkMachInt 0, mkTyApp (Var pAR_ERROR_ID) [betaTy])]
331 (BindDefault z (Var y))))
333 parGlobalId = pcMiscPrelId parGlobalIdKey cONC_BASE SLIT("parGlobal")
334 (mkSigmaTy [alphaTyVar, betaTyVar] []
335 (mkFunTys [intPrimTy, intPrimTy, intPrimTy, intPrimTy, alphaTy, betaTy] betaTy))
336 (noIdInfo `addUnfoldInfo` (mk_inline_unfolding parGlobal_template))
338 -- Annotations: w: name, g: gran. info, s: size info, p: par info -- HWL
339 [w, g, s, p, x, y, z]
351 = mkLam [alphaTyVar, betaTyVar] [w, g, s, p, x, y] (
352 Case (Prim ParGlobalOp [TyArg alphaTy, TyArg betaTy, VarArg x, VarArg w, VarArg g, VarArg s, VarArg p, VarArg y]) (
354 [(mkMachInt 0, mkTyApp (Var pAR_ERROR_ID) [betaTy])]
355 (BindDefault z (Var y))))
358 parAtId = pcMiscPrelId parAtIdKey cONC_BASE SLIT("parAt")
359 (mkSigmaTy [alphaTyVar, betaTyVar] []
360 (mkFunTys [intPrimTy, intPrimTy, intPrimTy, intPrimTy,
361 alphaTy, betaTy, gammaTy] gammaTy))
362 (noIdInfo `addUnfoldInfo` (mk_inline_unfolding parAt_template))
364 -- Annotations: w: name, g: gran. info, s: size info, p: par info -- HWL
365 [w, g, s, p, v, x, y, z]
378 = mkLam [alphaTyVar, betaTyVar, gammaTyVar] [w, g, s, p, v, x, y] (
379 Case (Prim ParAtOp [TyArg alphaTy, TyArg betaTy, TyArg gammaTy, VarArg x, VarArg v, VarArg w, VarArg g, VarArg s, VarArg p, VarArg y]) (
381 [(mkMachInt 0, mkTyApp (Var pAR_ERROR_ID) [gammaTy])]
382 (BindDefault z (Var y))))
384 parAtAbsId = pcMiscPrelId parAtAbsIdKey cONC_BASE SLIT("parAtAbs")
385 (mkSigmaTy [alphaTyVar, betaTyVar] []
386 (mkFunTys [intPrimTy, intPrimTy, intPrimTy, intPrimTy, intPrimTy, alphaTy, betaTy] betaTy))
387 (noIdInfo `addUnfoldInfo` (mk_inline_unfolding parAtAbs_template))
389 -- Annotations: w: name, g: gran. info, s: size info, p: par info -- HWL
390 [w, g, s, p, v, x, y, z]
403 = mkLam [alphaTyVar, betaTyVar] [w, g, s, p, v, x, y] (
404 Case (Prim ParAtAbsOp [TyArg alphaTy, TyArg betaTy, VarArg x, VarArg v, VarArg w, VarArg g, VarArg s, VarArg p, VarArg y]) (
406 [(mkMachInt 0, mkTyApp (Var pAR_ERROR_ID) [betaTy])]
407 (BindDefault z (Var y))))
409 parAtRelId = pcMiscPrelId parAtRelIdKey cONC_BASE SLIT("parAtRel")
410 (mkSigmaTy [alphaTyVar, betaTyVar] []
411 (mkFunTys [intPrimTy, intPrimTy, intPrimTy, intPrimTy, intPrimTy, alphaTy, betaTy] betaTy))
412 (noIdInfo `addUnfoldInfo` (mk_inline_unfolding parAtRel_template))
414 -- Annotations: w: name, g: gran. info, s: size info, p: par info -- HWL
415 [w, g, s, p, v, x, y, z]
428 = mkLam [alphaTyVar, betaTyVar] [w, g, s, p, v, x, y] (
429 Case (Prim ParAtRelOp [TyArg alphaTy, TyArg betaTy, VarArg x, VarArg v, VarArg w, VarArg g, VarArg s, VarArg p, VarArg y]) (
431 [(mkMachInt 0, mkTyApp (Var pAR_ERROR_ID) [betaTy])]
432 (BindDefault z (Var y))))
434 parAtForNowId = pcMiscPrelId parAtForNowIdKey cONC_BASE SLIT("parAtForNow")
435 (mkSigmaTy [alphaTyVar, betaTyVar] []
436 (mkFunTys [intPrimTy, intPrimTy, intPrimTy, intPrimTy,
437 alphaTy, betaTy, gammaTy] gammaTy))
438 (noIdInfo `addUnfoldInfo` (mk_inline_unfolding parAtForNow_template))
440 -- Annotations: w: name, g: gran. info, s: size info, p: par info -- HWL
441 [w, g, s, p, v, x, y, z]
454 = mkLam [alphaTyVar, betaTyVar, gammaTyVar] [w, g, s, p, v, x, y] (
455 Case (Prim ParAtForNowOp [TyArg alphaTy, TyArg betaTy, TyArg gammaTy, VarArg x, VarArg v, VarArg w, VarArg g, VarArg s, VarArg p, VarArg y]) (
457 [(mkMachInt 0, mkTyApp (Var pAR_ERROR_ID) [gammaTy])]
458 (BindDefault z (Var y))))
460 -- copyable and noFollow are currently merely hooks: they are translated into
461 -- calls to the macros COPYABLE and NOFOLLOW -- HWL
463 copyableId = pcMiscPrelId copyableIdKey cONC_BASE SLIT("copyable")
464 (mkSigmaTy [alphaTyVar] []
466 (noIdInfo `addUnfoldInfo` (mk_inline_unfolding copyable_template))
468 -- Annotations: x: closure that's tagged to by copyable
476 = mkLam [alphaTyVar] [x] ( Prim CopyableOp [TyArg alphaTy, VarArg x] )
478 noFollowId = pcMiscPrelId noFollowIdKey cONC_BASE SLIT("noFollow")
479 (mkSigmaTy [alphaTyVar] []
481 (noIdInfo `addUnfoldInfo` (mk_inline_unfolding noFollow_template))
483 -- Annotations: x: closure that's tagged to not follow
491 = mkLam [alphaTyVar] [x] ( Prim NoFollowOp [TyArg alphaTy, VarArg x] )
495 @realWorld#@ used to be a magic literal, \tr{void#}. If things get
496 nasty as-is, change it back to a literal (@Literal@).
499 = pcMiscPrelId realWorldPrimIdKey gHC__ SLIT("realWorld#")
505 voidId = pc_bottoming_Id voidIdKey pREL_BASE SLIT("void") voidTy
508 %************************************************************************
510 \subsection[PrelVals-foldr-build]{Values known about for ``foldr/build''}
512 %************************************************************************
516 = pcMiscPrelId buildIdKey gHC_ERR SLIT("build") buildTy
518 {-LATER:`addUnfoldInfo` mkMagicUnfolding buildIdKey-})
519 `addStrictnessInfo` mkStrictnessInfo [WwStrict] False)
520 `addArgUsageInfo` mkArgUsageInfo [ArgUsage 2])
521 `addSpecInfo` pcGenerateSpecs buildIdKey buildId noIdInfo{-ToDo-} buildTy)
522 -- cheating, but since _build never actually exists ...
524 -- The type of this strange object is:
525 -- \/ a . (\/ b . (a -> b -> b) -> b -> b) -> [a]
527 buildTy = mkSigmaTy [alphaTyVar] [] (mkFunTys [build_ty] (mkListTy alphaTy))
529 build_ty = mkSigmaTy [betaTyVar] []
530 (mkFunTys [mkFunTys [alphaTy, betaTy] betaTy, betaTy] betaTy)
533 @mkBuild@ is sugar for building a build!
535 @mkbuild ty tv c n e@ $Rightarrow$ @build ty (/\ tv -> \ c n -> e)@
536 @ty@ is the type of the list.
537 @tv@ is always a new type variable.
538 @c,n@ are Id's for the abstract cons and nil, @g@ for let binding the argument argument.
541 v :: (\/ b . (a -> b -> b) -> b -> b) -> [a]
542 -- \/ a . (\/ b . (a -> b -> b) -> b -> b) -> [a]
543 @e@ is the object right inside the @build@
551 -> CoreExpr -- template
552 -> CoreExpr -- template
554 mkBuild ty tv c n g expr
555 = Let (NonRec g (mkLam [tv] [c,n] expr))
556 (App (mkTyApp (Var buildId) [ty]) (VarArg g))
561 = pcMiscPrelId augmentIdKey gHC_ERR SLIT("augment") augmentTy
563 {-LATER:`addUnfoldInfo` mkMagicUnfolding augmentIdKey-})
564 `addStrictnessInfo` mkStrictnessInfo [WwStrict,WwLazy False] False)
565 `addArgUsageInfo` mkArgUsageInfo [ArgUsage 2,UnknownArgUsage])
566 -- cheating, but since _augment never actually exists ...
568 -- The type of this strange object is:
569 -- \/ a . (\/ b . (a -> b -> b) -> b -> b) -> [a] -> [a]
571 augmentTy = mkSigmaTy [alphaTyVar] [] (mkFunTys [aug_ty, mkListTy alphaTy] (mkListTy alphaTy))
573 aug_ty = mkSigmaTy [betaTyVar] []
574 (mkFunTys [mkFunTys [alphaTy, betaTy] betaTy, betaTy] betaTy)
578 foldrId = pcMiscPrelId foldrIdKey pREL_BASE SLIT("foldr")
582 mkSigmaTy [alphaTyVar, betaTyVar] []
583 (mkFunTys [mkFunTys [alphaTy, betaTy] betaTy, betaTy, mkListTy alphaTy] betaTy)
585 idInfo = (((((noIdInfo
586 {-LATER:`addUnfoldInfo` mkMagicUnfolding foldrIdKey-})
587 `addStrictnessInfo` mkStrictnessInfo [WwLazy False,WwLazy False,WwStrict] False)
588 `addArityInfo` exactArity 3)
589 `addUpdateInfo` mkUpdateInfo [2,2,1])
590 `addSpecInfo` pcGenerateSpecs foldrIdKey foldrId noIdInfo{-ToDo-} foldrTy)
592 foldlId = pcMiscPrelId foldlIdKey pREL_LIST SLIT("foldl")
596 mkSigmaTy [alphaTyVar, betaTyVar] []
597 (mkFunTys [mkFunTys [alphaTy, betaTy] alphaTy, alphaTy, mkListTy betaTy] alphaTy)
599 idInfo = (((((noIdInfo
600 {-LATER:`addUnfoldInfo` mkMagicUnfolding foldlIdKey-})
601 `addStrictnessInfo` mkStrictnessInfo [WwLazy False,WwLazy False,WwStrict] False)
602 `addArityInfo` exactArity 3)
603 `addUpdateInfo` mkUpdateInfo [2,2,1])
604 `addSpecInfo` pcGenerateSpecs foldlIdKey foldlId noIdInfo{-ToDo-} foldlTy)
606 -- A bit of magic goes no here. We translate appendId into ++,
607 -- you have to be carefull when you actually compile append:
608 -- xs ++ ys = augment (\ c n -> foldr c n xs) ys
609 -- {- unfold augment -}
611 -- {- fold foldr to append -}
612 -- = ys `appendId` xs
613 -- = ys ++ xs -- ugg!
614 -- *BUT* you want (++) and not _append in your interfaces.
616 -- So you have to turn *off* unfolding of foldr inside FoldrBuild.hs inside
619 {- OLD: doesn't apply with 1.3
621 = pcMiscPrelId appendIdKey mONAD SLIT("++") appendTy idInfo
624 (mkSigmaTy [alphaTyVar] []
625 (mkFunTys [mkListTy alphaTy, mkListTy alphaTy] (mkListTy alphaTy)))
627 `addStrictnessInfo` mkStrictnessInfo [WwStrict,WwLazy False] False)
628 `addArityInfo` exactArity 2)
629 `addUpdateInfo` mkUpdateInfo [1,2])
633 %************************************************************************
635 \subsection[PrelUtils-specialisations]{Specialisations for builtin values}
637 %************************************************************************
639 The specialisations which exist for the builtin values must be recorded in
642 NOTE: THE USES OF THE pcGenerate... FUNCTIONS MUST CORRESPOND
643 TO THE SPECIALISATIONS DECLARED IN THE PRELUDE !!!
645 HACK: We currently use the same unique for the specialised Ids.
647 The list @specing_types@ determines the types for which specialised
648 versions are created. Note: This should correspond with the
649 types passed to the pre-processor with the -genSPECS arg (see ghc.lprl).
651 ToDo: Create single mkworld definition which is grabbed here and in ghc.lprl
654 pcGenerateSpecs :: Unique -> Id -> IdInfo -> Type -> SpecEnv
655 pcGenerateSpecs key id info ty
660 pc_gen_specs True key id info ty
662 pc_gen_specs is_id key id info ty
663 = mkSpecEnv spec_infos
665 spec_infos = [ let spec_ty = specialiseTy ty spec_tys 0
667 then mkSpecId key {- HACK WARNING: same unique! -}
668 id spec_tys spec_ty info
669 else panic "SpecData:SpecInfo:SpecId"
671 SpecInfo spec_tys (length ctxts) spec_id
672 | spec_tys <- specialisations ]
674 (tyvars, ctxts, _) = splitSigmaTy ty
675 no_tyvars = length tyvars
677 specialisations = if no_tyvars == 0
679 else tail (cross_product no_tyvars specing_types)
681 -- N.B. tail removes fully polymorphic specialisation
683 cross_product 0 tys = []
684 cross_product 1 tys = map (:[]) tys
685 cross_product n tys = concat [map (:cp) tys | cp <- cross_product (n-1) tys]
688 specing_types = [Nothing,