2 % (c) The GRASP Project, Glasgow University, 1994-1995
4 \section[TysWiredIn]{Wired-in knowledge about {\em non-primitive} types}
6 This module is about types that can be defined in Haskell, but which
7 must be wired into the compiler nonetheless.
9 This module tracks the ``state interface'' document, ``GHC prelude:
10 types and operations.''
13 #include "HsVersions.h"
32 getStatePairingConInfo,
57 stateAndAddrPrimTyCon,
58 stateAndArrayPrimTyCon,
59 stateAndByteArrayPrimTyCon,
60 stateAndCharPrimTyCon,
61 stateAndDoublePrimTyCon,
62 stateAndFloatPrimTyCon,
64 stateAndForeignObjPrimTyCon,
65 stateAndMutableArrayPrimTyCon,
66 stateAndMutableByteArrayPrimTyCon,
68 stateAndStablePtrPrimTyCon,
69 stateAndSynchVarPrimTyCon,
70 stateAndWordPrimTyCon,
89 IMPORT_DELOOPER(TyLoop) ( mkDataCon, StrictnessMark(..) )
96 import SpecEnv ( SYN_IE(SpecEnv) )
97 import Kind ( mkBoxedTypeKind, mkArrowKind )
98 import Name ( mkWiredInName, ExportFlag(..) )
99 import SrcLoc ( mkBuiltinSrcLoc )
100 import TyCon ( mkDataTyCon, mkTupleTyCon, mkSynTyCon,
103 import Type ( mkTyConTy, applyTyCon, mkSigmaTy,
104 mkFunTys, maybeAppTyCon,
105 GenType(..), SYN_IE(ThetaType), SYN_IE(TauType) )
106 import TyVar ( tyVarKind, alphaTyVar, betaTyVar )
108 import Util ( assoc, panic )
110 nullSpecEnv = error "TysWiredIn:nullSpecEnv = "
111 addOneToSpecEnv = error "TysWiredIn:addOneToSpecEnv = "
112 pc_gen_specs = error "TysWiredIn:pc_gen_specs "
113 mkSpecInfo = error "TysWiredIn:SpecInfo"
115 alpha_tyvar = [alphaTyVar]
117 alpha_beta_tyvars = [alphaTyVar, betaTyVar]
119 pcDataTyCon, pcNewTyCon
120 :: Unique{-TyConKey-} -> Module -> FAST_STRING
121 -> [TyVar] -> [Id] -> TyCon
123 pcDataTyCon = pc_tycon DataType
124 pcNewTyCon = pc_tycon NewType
126 pc_tycon new_or_data key mod str tyvars cons
127 = mkDataTyCon (mkWiredInName key (OrigName mod str) ExportAll) tycon_kind
128 tyvars [{-no context-}] cons [{-no derivings-}]
131 tycon_kind = foldr (mkArrowKind . tyVarKind) mkBoxedTypeKind tyvars
133 pcDataCon :: Unique{-DataConKey-} -> Module -> FAST_STRING
134 -> [TyVar] -> ThetaType -> [TauType] -> TyCon -> SpecEnv -> Id
135 pcDataCon key mod str tyvars context arg_tys tycon specenv
136 = mkDataCon (mkWiredInName key (OrigName mod str) ExportAll)
137 [ NotMarkedStrict | a <- arg_tys ]
138 [ {- no labelled fields -} ]
139 tyvars context arg_tys tycon
142 pcGenerateDataSpecs :: Type -> SpecEnv
143 pcGenerateDataSpecs ty
144 = pc_gen_specs False err err err ty
146 err = panic "PrelUtils:GenerateDataSpecs"
149 %************************************************************************
151 \subsection[TysWiredIn-boxed-prim]{The ``boxed primitive'' types (@Char@, @Int@, etc)}
153 %************************************************************************
156 charTy = mkTyConTy charTyCon
158 charTyCon = pcDataTyCon charTyConKey pRELUDE SLIT("Char") [] [charDataCon]
159 charDataCon = pcDataCon charDataConKey pRELUDE SLIT("C#") [] [] [charPrimTy] charTyCon nullSpecEnv
161 stringTy = mkListTy charTy -- convenience only
165 intTy = mkTyConTy intTyCon
167 intTyCon = pcDataTyCon intTyConKey pRELUDE SLIT("Int") [] [intDataCon]
168 intDataCon = pcDataCon intDataConKey pRELUDE SLIT("I#") [] [] [intPrimTy] intTyCon nullSpecEnv
172 wordTy = mkTyConTy wordTyCon
174 wordTyCon = pcDataTyCon wordTyConKey gHC__ SLIT("Word") [] [wordDataCon]
175 wordDataCon = pcDataCon wordDataConKey gHC__ SLIT("W#") [] [] [wordPrimTy] wordTyCon nullSpecEnv
179 addrTy = mkTyConTy addrTyCon
181 addrTyCon = pcDataTyCon addrTyConKey gHC__ SLIT("Addr") [] [addrDataCon]
182 addrDataCon = pcDataCon addrDataConKey gHC__ SLIT("A#") [] [] [addrPrimTy] addrTyCon nullSpecEnv
186 floatTy = mkTyConTy floatTyCon
188 floatTyCon = pcDataTyCon floatTyConKey pRELUDE SLIT("Float") [] [floatDataCon]
189 floatDataCon = pcDataCon floatDataConKey pRELUDE SLIT("F#") [] [] [floatPrimTy] floatTyCon nullSpecEnv
193 doubleTy = mkTyConTy doubleTyCon
195 doubleTyCon = pcDataTyCon doubleTyConKey pRELUDE SLIT("Double") [] [doubleDataCon]
196 doubleDataCon = pcDataCon doubleDataConKey pRELUDE SLIT("D#") [] [] [doublePrimTy] doubleTyCon nullSpecEnv
200 mkStateTy ty = applyTyCon stateTyCon [ty]
201 realWorldStateTy = mkStateTy realWorldTy -- a common use
203 stateTyCon = pcDataTyCon stateTyConKey gHC__ SLIT("State") alpha_tyvar [stateDataCon]
205 = pcDataCon stateDataConKey gHC__ SLIT("S#")
206 alpha_tyvar [] [mkStatePrimTy alphaTy] stateTyCon nullSpecEnv
211 = pcDataTyCon stablePtrTyConKey gHC__ SLIT("StablePtr")
212 alpha_tyvar [stablePtrDataCon]
215 = pcDataCon stablePtrDataConKey gHC__ SLIT("StablePtr")
216 alpha_tyvar [] [mkStablePtrPrimTy alphaTy] stablePtrTyCon nullSpecEnv
221 = pcDataTyCon foreignObjTyConKey gHC__ SLIT("ForeignObj")
222 [] [foreignObjDataCon]
225 = pcDataCon foreignObjDataConKey gHC__ SLIT("ForeignObj")
226 [] [] [foreignObjPrimTy] foreignObjTyCon nullSpecEnv
229 %************************************************************************
231 \subsection[TysWiredIn-Integer]{@Integer@ and its related ``pairing'' types}
233 %************************************************************************
235 @Integer@ and its pals are not really primitive. @Integer@ itself, first:
237 integerTy :: GenType t u
238 integerTy = mkTyConTy integerTyCon
240 integerTyCon = pcDataTyCon integerTyConKey pRELUDE SLIT("Integer") [] [integerDataCon]
242 integerDataCon = pcDataCon integerDataConKey pRELUDE SLIT("J#")
243 [] [] [intPrimTy, intPrimTy, byteArrayPrimTy] integerTyCon nullSpecEnv
246 And the other pairing types:
248 return2GMPsTyCon = pcDataTyCon return2GMPsTyConKey
249 gHC__ SLIT("Return2GMPs") [] [return2GMPsDataCon]
252 = pcDataCon return2GMPsDataConKey gHC__ SLIT("Return2GMPs") [] []
253 [intPrimTy, intPrimTy, byteArrayPrimTy,
254 intPrimTy, intPrimTy, byteArrayPrimTy] return2GMPsTyCon nullSpecEnv
256 returnIntAndGMPTyCon = pcDataTyCon returnIntAndGMPTyConKey
257 gHC__ SLIT("ReturnIntAndGMP") [] [returnIntAndGMPDataCon]
259 returnIntAndGMPDataCon
260 = pcDataCon returnIntAndGMPDataConKey gHC__ SLIT("ReturnIntAndGMP") [] []
261 [intPrimTy, intPrimTy, intPrimTy, byteArrayPrimTy] returnIntAndGMPTyCon nullSpecEnv
264 %************************************************************************
266 \subsection[TysWiredIn-state-pairing]{``State-pairing'' types}
268 %************************************************************************
270 These boring types pair a \tr{State#} with another primitive type.
271 They are not really primitive, so they are given here, not in
274 We fish one of these \tr{StateAnd<blah>#} things with
275 @getStatePairingConInfo@ (given a little way down).
279 = pcDataTyCon stateAndPtrPrimTyConKey gHC__ SLIT("StateAndPtr#")
280 alpha_beta_tyvars [stateAndPtrPrimDataCon]
281 stateAndPtrPrimDataCon
282 = pcDataCon stateAndPtrPrimDataConKey gHC__ SLIT("StateAndPtr#")
283 alpha_beta_tyvars [] [mkStatePrimTy alphaTy, betaTy]
284 stateAndPtrPrimTyCon nullSpecEnv
286 stateAndCharPrimTyCon
287 = pcDataTyCon stateAndCharPrimTyConKey gHC__ SLIT("StateAndChar#")
288 alpha_tyvar [stateAndCharPrimDataCon]
289 stateAndCharPrimDataCon
290 = pcDataCon stateAndCharPrimDataConKey gHC__ SLIT("StateAndChar#")
291 alpha_tyvar [] [mkStatePrimTy alphaTy, charPrimTy]
292 stateAndCharPrimTyCon nullSpecEnv
295 = pcDataTyCon stateAndIntPrimTyConKey gHC__ SLIT("StateAndInt#")
296 alpha_tyvar [stateAndIntPrimDataCon]
297 stateAndIntPrimDataCon
298 = pcDataCon stateAndIntPrimDataConKey gHC__ SLIT("StateAndInt#")
299 alpha_tyvar [] [mkStatePrimTy alphaTy, intPrimTy]
300 stateAndIntPrimTyCon nullSpecEnv
302 stateAndWordPrimTyCon
303 = pcDataTyCon stateAndWordPrimTyConKey gHC__ SLIT("StateAndWord#")
304 alpha_tyvar [stateAndWordPrimDataCon]
305 stateAndWordPrimDataCon
306 = pcDataCon stateAndWordPrimDataConKey gHC__ SLIT("StateAndWord#")
307 alpha_tyvar [] [mkStatePrimTy alphaTy, wordPrimTy]
308 stateAndWordPrimTyCon nullSpecEnv
310 stateAndAddrPrimTyCon
311 = pcDataTyCon stateAndAddrPrimTyConKey gHC__ SLIT("StateAndAddr#")
312 alpha_tyvar [stateAndAddrPrimDataCon]
313 stateAndAddrPrimDataCon
314 = pcDataCon stateAndAddrPrimDataConKey gHC__ SLIT("StateAndAddr#")
315 alpha_tyvar [] [mkStatePrimTy alphaTy, addrPrimTy]
316 stateAndAddrPrimTyCon nullSpecEnv
318 stateAndStablePtrPrimTyCon
319 = pcDataTyCon stateAndStablePtrPrimTyConKey gHC__ SLIT("StateAndStablePtr#")
320 alpha_beta_tyvars [stateAndStablePtrPrimDataCon]
321 stateAndStablePtrPrimDataCon
322 = pcDataCon stateAndStablePtrPrimDataConKey gHC__ SLIT("StateAndStablePtr#")
324 [mkStatePrimTy alphaTy, applyTyCon stablePtrPrimTyCon [betaTy]]
325 stateAndStablePtrPrimTyCon nullSpecEnv
327 stateAndForeignObjPrimTyCon
328 = pcDataTyCon stateAndForeignObjPrimTyConKey gHC__ SLIT("StateAndForeignObj#")
329 alpha_tyvar [stateAndForeignObjPrimDataCon]
330 stateAndForeignObjPrimDataCon
331 = pcDataCon stateAndForeignObjPrimDataConKey gHC__ SLIT("StateAndForeignObj#")
333 [mkStatePrimTy alphaTy, applyTyCon foreignObjPrimTyCon []]
334 stateAndForeignObjPrimTyCon nullSpecEnv
336 stateAndFloatPrimTyCon
337 = pcDataTyCon stateAndFloatPrimTyConKey gHC__ SLIT("StateAndFloat#")
338 alpha_tyvar [stateAndFloatPrimDataCon]
339 stateAndFloatPrimDataCon
340 = pcDataCon stateAndFloatPrimDataConKey gHC__ SLIT("StateAndFloat#")
341 alpha_tyvar [] [mkStatePrimTy alphaTy, floatPrimTy]
342 stateAndFloatPrimTyCon nullSpecEnv
344 stateAndDoublePrimTyCon
345 = pcDataTyCon stateAndDoublePrimTyConKey gHC__ SLIT("StateAndDouble#")
346 alpha_tyvar [stateAndDoublePrimDataCon]
347 stateAndDoublePrimDataCon
348 = pcDataCon stateAndDoublePrimDataConKey gHC__ SLIT("StateAndDouble#")
349 alpha_tyvar [] [mkStatePrimTy alphaTy, doublePrimTy]
350 stateAndDoublePrimTyCon nullSpecEnv
354 stateAndArrayPrimTyCon
355 = pcDataTyCon stateAndArrayPrimTyConKey gHC__ SLIT("StateAndArray#")
356 alpha_beta_tyvars [stateAndArrayPrimDataCon]
357 stateAndArrayPrimDataCon
358 = pcDataCon stateAndArrayPrimDataConKey gHC__ SLIT("StateAndArray#")
359 alpha_beta_tyvars [] [mkStatePrimTy alphaTy, mkArrayPrimTy betaTy]
360 stateAndArrayPrimTyCon nullSpecEnv
362 stateAndMutableArrayPrimTyCon
363 = pcDataTyCon stateAndMutableArrayPrimTyConKey gHC__ SLIT("StateAndMutableArray#")
364 alpha_beta_tyvars [stateAndMutableArrayPrimDataCon]
365 stateAndMutableArrayPrimDataCon
366 = pcDataCon stateAndMutableArrayPrimDataConKey gHC__ SLIT("StateAndMutableArray#")
367 alpha_beta_tyvars [] [mkStatePrimTy alphaTy, mkMutableArrayPrimTy alphaTy betaTy]
368 stateAndMutableArrayPrimTyCon nullSpecEnv
370 stateAndByteArrayPrimTyCon
371 = pcDataTyCon stateAndByteArrayPrimTyConKey gHC__ SLIT("StateAndByteArray#")
372 alpha_tyvar [stateAndByteArrayPrimDataCon]
373 stateAndByteArrayPrimDataCon
374 = pcDataCon stateAndByteArrayPrimDataConKey gHC__ SLIT("StateAndByteArray#")
375 alpha_tyvar [] [mkStatePrimTy alphaTy, byteArrayPrimTy]
376 stateAndByteArrayPrimTyCon nullSpecEnv
378 stateAndMutableByteArrayPrimTyCon
379 = pcDataTyCon stateAndMutableByteArrayPrimTyConKey gHC__ SLIT("StateAndMutableByteArray#")
380 alpha_tyvar [stateAndMutableByteArrayPrimDataCon]
381 stateAndMutableByteArrayPrimDataCon
382 = pcDataCon stateAndMutableByteArrayPrimDataConKey gHC__ SLIT("StateAndMutableByteArray#")
383 alpha_tyvar [] [mkStatePrimTy alphaTy, applyTyCon mutableByteArrayPrimTyCon alpha_ty]
384 stateAndMutableByteArrayPrimTyCon nullSpecEnv
386 stateAndSynchVarPrimTyCon
387 = pcDataTyCon stateAndSynchVarPrimTyConKey gHC__ SLIT("StateAndSynchVar#")
388 alpha_beta_tyvars [stateAndSynchVarPrimDataCon]
389 stateAndSynchVarPrimDataCon
390 = pcDataCon stateAndSynchVarPrimDataConKey gHC__ SLIT("StateAndSynchVar#")
391 alpha_beta_tyvars [] [mkStatePrimTy alphaTy, mkSynchVarPrimTy alphaTy betaTy]
392 stateAndSynchVarPrimTyCon nullSpecEnv
395 The ccall-desugaring mechanism uses this function to figure out how to
396 rebox the result. It's really a HACK, especially the part about
397 how many types to drop from \tr{tys_applied}.
400 getStatePairingConInfo
401 :: Type -- primitive type
402 -> (Id, -- state pair constructor for prim type
403 Type) -- type of state pair
405 getStatePairingConInfo prim_ty
406 = case (maybeAppTyCon prim_ty) of
407 Nothing -> panic "getStatePairingConInfo:1"
408 Just (prim_tycon, tys_applied) ->
410 (pair_con, pair_tycon, num_tys) = assoc "getStatePairingConInfo" tbl prim_tycon
411 pair_ty = applyTyCon pair_tycon (realWorldTy : drop num_tys tys_applied)
416 (charPrimTyCon, (stateAndCharPrimDataCon, stateAndCharPrimTyCon, 0)),
417 (intPrimTyCon, (stateAndIntPrimDataCon, stateAndIntPrimTyCon, 0)),
418 (wordPrimTyCon, (stateAndWordPrimDataCon, stateAndWordPrimTyCon, 0)),
419 (addrPrimTyCon, (stateAndAddrPrimDataCon, stateAndAddrPrimTyCon, 0)),
420 (stablePtrPrimTyCon, (stateAndStablePtrPrimDataCon, stateAndStablePtrPrimTyCon, 0)),
421 (foreignObjPrimTyCon, (stateAndForeignObjPrimDataCon, stateAndForeignObjPrimTyCon, 0)),
422 (floatPrimTyCon, (stateAndFloatPrimDataCon, stateAndFloatPrimTyCon, 0)),
423 (doublePrimTyCon, (stateAndDoublePrimDataCon, stateAndDoublePrimTyCon, 0)),
424 (arrayPrimTyCon, (stateAndArrayPrimDataCon, stateAndArrayPrimTyCon, 0)),
425 (mutableArrayPrimTyCon, (stateAndMutableArrayPrimDataCon, stateAndMutableArrayPrimTyCon, 1)),
426 (byteArrayPrimTyCon, (stateAndByteArrayPrimDataCon, stateAndByteArrayPrimTyCon, 0)),
427 (mutableByteArrayPrimTyCon, (stateAndMutableByteArrayPrimDataCon, stateAndMutableByteArrayPrimTyCon, 1)),
428 (synchVarPrimTyCon, (stateAndSynchVarPrimDataCon, stateAndSynchVarPrimTyCon, 1))
429 -- (PtrPrimTyCon, (stateAndPtrPrimDataCon, stateAndPtrPrimTyCon, 0)),
433 %************************************************************************
435 \subsection[TysWiredIn-ST]{The basic @_ST@ state-transformer type}
437 %************************************************************************
439 This is really just an ordinary synonym, except it is ABSTRACT.
442 mkStateTransformerTy s a = applyTyCon stTyCon [s, a]
444 stTyCon = pcNewTyCon stTyConKey gHC__ SLIT("ST") alpha_beta_tyvars [stDataCon]
446 ty = mkFunTys [mkStateTy alphaTy] (mkTupleTy 2 [betaTy, mkStateTy alphaTy])
448 stDataCon = pcDataCon stDataConKey gHC__ SLIT("ST")
449 alpha_beta_tyvars [] [ty] stTyCon nullSpecEnv
452 %************************************************************************
454 \subsection[TysWiredIn-IO]{The @PrimIO@ and @IO@ monadic-I/O types}
456 %************************************************************************
459 mkPrimIoTy a = applyTyCon primIoTyCon [a]
461 primIoTyCon = pcNewTyCon primIoTyConKey gHC__ SLIT("PrimIO") alpha_tyvar [primIoDataCon]
463 primIoDataCon = pcDataCon primIoDataConKey gHC__ SLIT("PrimIO")
464 alpha_tyvar [] [ty] primIoTyCon nullSpecEnv
466 ty = mkFunTys [mkStateTy realWorldTy] (mkTupleTy 2 [alphaTy, mkStateTy realWorldTy])
469 %************************************************************************
471 \subsection[TysWiredIn-Bool]{The @Bool@ type}
473 %************************************************************************
475 An ordinary enumeration type, but deeply wired in. There are no
476 magical operations on @Bool@ (just the regular Prelude code).
478 {\em BEGIN IDLE SPECULATION BY SIMON}
480 This is not the only way to encode @Bool@. A more obvious coding makes
481 @Bool@ just a boxed up version of @Bool#@, like this:
484 data Bool = MkBool Bool#
487 Unfortunately, this doesn't correspond to what the Report says @Bool@
488 looks like! Furthermore, we get slightly less efficient code (I
489 think) with this coding. @gtInt@ would look like this:
492 gtInt :: Int -> Int -> Bool
493 gtInt x y = case x of I# x# ->
495 case (gtIntPrim x# y#) of
499 Notice that the result of the @gtIntPrim@ comparison has to be turned
500 into an integer (here called @b#@), and returned in a @MkBool@ box.
502 The @if@ expression would compile to this:
505 MkBool b# -> case b# of { 1# -> e1; 0# -> e2 }
508 I think this code is a little less efficient than the previous code,
509 but I'm not certain. At all events, corresponding with the Report is
510 important. The interesting thing is that the language is expressive
511 enough to describe more than one alternative; and that a type doesn't
512 necessarily need to be a straightforwardly boxed version of its
513 primitive counterpart.
515 {\em END IDLE SPECULATION BY SIMON}
518 boolTy = mkTyConTy boolTyCon
520 boolTyCon = pcDataTyCon boolTyConKey pRELUDE SLIT("Bool") [] [falseDataCon, trueDataCon]
522 falseDataCon = pcDataCon falseDataConKey pRELUDE SLIT("False") [] [] [] boolTyCon nullSpecEnv
523 trueDataCon = pcDataCon trueDataConKey pRELUDE SLIT("True") [] [] [] boolTyCon nullSpecEnv
526 %************************************************************************
528 \subsection[TysWiredIn-List]{The @List@ type (incl ``build'' magic)}
530 %************************************************************************
532 Special syntax, deeply wired in, but otherwise an ordinary algebraic
535 data [] a = [] | a : (List a)
537 data (,) a b = (,,) a b
542 mkListTy :: GenType t u -> GenType t u
543 mkListTy ty = applyTyCon listTyCon [ty]
545 alphaListTy = mkSigmaTy alpha_tyvar [] (applyTyCon listTyCon alpha_ty)
547 listTyCon = pcDataTyCon listTyConKey pRELUDE SLIT("[]")
548 alpha_tyvar [nilDataCon, consDataCon]
550 nilDataCon = pcDataCon nilDataConKey pRELUDE SLIT("[]") alpha_tyvar [] [] listTyCon
551 (pcGenerateDataSpecs alphaListTy)
552 consDataCon = pcDataCon consDataConKey pRELUDE SLIT(":")
553 alpha_tyvar [] [alphaTy, applyTyCon listTyCon alpha_ty] listTyCon
554 (pcGenerateDataSpecs alphaListTy)
555 -- Interesting: polymorphic recursion would help here.
556 -- We can't use (mkListTy alphaTy) in the defn of consDataCon, else mkListTy
557 -- gets the over-specific type (Type -> Type)
560 %************************************************************************
562 \subsection[TysWiredIn-Tuples]{The @Tuple@ types}
564 %************************************************************************
566 The tuple types are definitely magic, because they form an infinite
571 They have a special family of type constructors, of type @TyCon@
572 These contain the tycon arity, but don't require a Unique.
575 They have a special family of constructors, of type
576 @Id@. Again these contain their arity but don't need a Unique.
579 There should be a magic way of generating the info tables and
580 entry code for all tuples.
582 But at the moment we just compile a Haskell source
583 file\srcloc{lib/prelude/...} containing declarations like:
586 data Tuple2 a b = Tup2 a b
587 data Tuple3 a b c = Tup3 a b c
588 data Tuple4 a b c d = Tup4 a b c d
591 The print-names associated with the magic @Id@s for tuple constructors
592 ``just happen'' to be the same as those generated by these
596 The instance environment should have a magic way to know
597 that each tuple type is an instances of classes @Eq@, @Ix@, @Ord@ and
598 so on. \ToDo{Not implemented yet.}
601 There should also be a way to generate the appropriate code for each
602 of these instances, but (like the info tables and entry code) it is
603 done by enumeration\srcloc{lib/prelude/InTup?.hs}.
607 mkTupleTy :: Int -> [GenType t u] -> GenType t u
609 mkTupleTy arity tys = applyTyCon (mkTupleTyCon arity) tys
611 unitTy = mkTupleTy 0 []
614 %************************************************************************
616 \subsection[TysWiredIn-_Lift]{@_Lift@ type: to support array indexing}
618 %************************************************************************
620 Again, deeply turgid: \tr{data _Lift a = _Lift a}.
623 mkLiftTy ty = applyTyCon liftTyCon [ty]
627 = mkSigmaTy tvs theta (applyTyCon liftTyCon [tau])
629 (tvs, theta, tau) = splitSigmaTy ty
632 = case (maybeAppDataTyConExpandingDicts tau) of
633 Just (tycon, tys, _) -> tycon == liftTyCon
636 (tvs, theta, tau) = splitSigmaTy ty
640 alphaLiftTy = mkSigmaTy alpha_tyvar [] (applyTyCon liftTyCon alpha_ty)
643 = pcDataTyCon liftTyConKey gHC__ SLIT("Lift") alpha_tyvar [liftDataCon]
646 = pcDataCon liftDataConKey gHC__ SLIT("Lift")
647 alpha_tyvar [] alpha_ty liftTyCon
648 ((pcGenerateDataSpecs alphaLiftTy) `addOneToSpecEnv`
649 (mkSpecInfo [Just realWorldStatePrimTy] 0 bottom))
651 bottom = panic "liftDataCon:State# _RealWorld"