9e3dbfbd549cb3173e4930f717a42bca82e73ed4
[ghc-hetmet.git] / ghc / compiler / prelude / TysWiredIn.lhs
1 %
2 % (c) The GRASP Project, Glasgow University, 1994-1998
3 %
4 \section[TysWiredIn]{Wired-in knowledge about {\em non-primitive} types}
5
6 This module is about types that can be defined in Haskell, but which
7 must be wired into the compiler nonetheless.
8
9 This module tracks the ``state interface'' document, ``GHC prelude:
10 types and operations.''
11
12 \begin{code}
13 module TysWiredIn (
14         wiredInTyCons, genericTyCons,
15
16         addrDataCon,
17         addrTy,
18         addrTyCon,
19         ptrDataCon,
20         ptrTy,
21         ptrTyCon,
22         funPtrDataCon,
23         funPtrTy,
24         funPtrTyCon,
25         boolTy,
26         boolTyCon,
27         charDataCon,
28         charTy,
29         charTyCon,
30         consDataCon,
31         doubleDataCon,
32         doubleTy,
33         doubleTyCon,
34         falseDataCon, falseDataConId,
35         floatDataCon,
36         floatTy,
37         floatTyCon,
38
39         intDataCon,
40         intTy,
41         intTyCon,
42
43         integerTy,
44         integerTyCon,
45         smallIntegerDataCon,
46         largeIntegerDataCon,
47
48         listTyCon,
49
50         mkListTy,
51         nilDataCon,
52
53         -- tuples
54         mkTupleTy,
55         tupleTyCon, tupleCon, 
56         unitTyCon, unitDataCon, unitDataConId, pairTyCon, 
57         unboxedSingletonTyCon, unboxedSingletonDataCon,
58         unboxedPairTyCon, unboxedPairDataCon,
59
60         -- Generics
61         genUnitTyCon, genUnitDataCon, 
62         plusTyCon, inrDataCon, inlDataCon,
63         crossTyCon, crossDataCon,
64
65         stablePtrTyCon,
66         stringTy,
67         trueDataCon, trueDataConId,
68         unitTy,
69         voidTy,
70         wordDataCon,
71         wordTy,
72         wordTyCon,
73
74         -- parallel arrays
75         mkPArrTy,
76         parrTyCon, parrFakeCon, isPArrTyCon, isPArrFakeCon
77     ) where
78
79 #include "HsVersions.h"
80
81 import {-# SOURCE #-} MkId( mkDataConWorkId )
82 import {-# SOURCE #-} Generics( mkTyConGenInfo )
83
84 -- friends:
85 import PrelNames
86 import TysPrim
87
88 -- others:
89 import Constants        ( mAX_TUPLE_SIZE )
90 import Module           ( mkBasePkgModule )
91 import Name             ( Name, nameUnique, nameOccName, 
92                           nameModule, mkWiredInName )
93 import OccName          ( mkOccFS, tcName, dataName, mkDataConWorkerOcc, mkGenOcc1, mkGenOcc2 )
94 import DataCon          ( DataCon, mkDataCon, dataConWorkId, dataConSourceArity )
95 import Var              ( TyVar, tyVarKind )
96 import TyCon            ( TyCon, AlgTyConFlavour(..), DataConDetails(..), tyConDataCons,
97                           mkTupleTyCon, mkAlgTyCon, tyConName
98                         )
99
100 import BasicTypes       ( Arity, RecFlag(..), Boxity(..), isBoxed )
101
102 import Type             ( Type, mkTyConTy, mkTyConApp, mkTyVarTy, mkTyVarTys, 
103                           mkArrowKinds, liftedTypeKind, unliftedTypeKind,
104                           ThetaType )
105 import Unique           ( incrUnique, mkTupleTyConUnique,
106                           mkTupleDataConUnique, mkPArrDataConUnique )
107 import PrelNames
108 import Array
109 import FastString
110
111 alpha_tyvar       = [alphaTyVar]
112 alpha_ty          = [alphaTy]
113 alpha_beta_tyvars = [alphaTyVar, betaTyVar]
114 \end{code}
115
116
117 %************************************************************************
118 %*                                                                      *
119 \subsection{Wired in type constructors}
120 %*                                                                      *
121 %************************************************************************
122
123 If you change which things are wired in, make sure you change their
124 names in PrelNames, so they use wTcQual, wDataQual, etc
125
126 \begin{code}
127 wiredInTyCons :: [TyCon]
128 wiredInTyCons = data_tycons ++ tuple_tycons ++ unboxed_tuple_tycons
129
130 data_tycons = genericTyCons ++
131               [ addrTyCon
132               , ptrTyCon
133               , funPtrTyCon
134               , boolTyCon
135               , charTyCon
136               , doubleTyCon
137               , floatTyCon
138               , intTyCon
139               , integerTyCon
140               , listTyCon
141               , parrTyCon
142               , wordTyCon
143               ]
144
145 genericTyCons :: [TyCon]
146 genericTyCons = [ plusTyCon, crossTyCon, genUnitTyCon ]
147
148 tuple_tycons = unitTyCon : [tupleTyCon Boxed   i | i <- [2..mAX_TUPLE_SIZE] ]
149 unboxed_tuple_tycons     = [tupleTyCon Unboxed i | i <- [1..mAX_TUPLE_SIZE] ]
150 \end{code}
151
152
153 %************************************************************************
154 %*                                                                      *
155 \subsection{mkWiredInTyCon}
156 %*                                                                      *
157 %************************************************************************
158
159 \begin{code}
160 pcNonRecDataTyCon = pcTyCon DataTyCon NonRecursive
161 pcRecDataTyCon = pcTyCon DataTyCon Recursive
162
163 pcTyCon new_or_data is_rec name tyvars argvrcs cons
164   = tycon
165   where
166     tycon = mkAlgTyCon name kind
167                 tyvars
168                 []              -- No context
169                 argvrcs
170                 (DataCons cons)
171                 []              -- No record selectors
172                 new_or_data
173                 is_rec
174                 gen_info
175
176     mod      = nameModule name
177     kind     = mkArrowKinds (map tyVarKind tyvars) liftedTypeKind
178     gen_info = mk_tc_gen_info mod (nameUnique name) name tycon
179
180 -- We generate names for the generic to/from Ids by incrementing
181 -- the TyCon unique.  So each Prelude tycon needs 3 slots, one
182 -- for itself and two more for the generic Ids.
183 mk_tc_gen_info mod tc_uniq tc_name tycon
184   = mkTyConGenInfo tycon [name1, name2]
185   where
186         tc_occ_name = nameOccName tc_name
187         occ_name1   = mkGenOcc1 tc_occ_name
188         occ_name2   = mkGenOcc2 tc_occ_name
189         fn1_key     = incrUnique tc_uniq
190         fn2_key     = incrUnique fn1_key
191         name1       = mkWiredInName  mod occ_name1 fn1_key
192         name2       = mkWiredInName  mod occ_name2 fn2_key
193
194 pcDataCon :: Name -> [TyVar] -> ThetaType -> [Type] -> TyCon -> DataCon
195 -- The Name should be in the DataName name space; it's the name
196 -- of the DataCon itself.
197 --
198 -- The unique is the first of two free uniques;
199 -- the first is used for the datacon itself,
200 -- the second is used for the "worker name"
201
202 pcDataCon dc_name tyvars context arg_tys tycon
203   = data_con
204   where
205     data_con = mkDataCon dc_name        
206                 [{- No strictness -}]
207                 [{- No labelled fields -}]
208                 tyvars context [] [] arg_tys tycon work_id 
209                 Nothing {- No wrapper for wired-in things
210                            (they are too simple to need one) -}
211
212     mod      = nameModule dc_name
213     wrk_occ  = mkDataConWorkerOcc (nameOccName dc_name)
214     wrk_key  = incrUnique (nameUnique dc_name)
215     wrk_name = mkWiredInName mod wrk_occ wrk_key
216     work_id  = mkDataConWorkId wrk_name data_con
217 \end{code}
218
219
220 %************************************************************************
221 %*                                                                      *
222 \subsection[TysWiredIn-tuples]{The tuple types}
223 %*                                                                      *
224 %************************************************************************
225
226 \begin{code}
227 tupleTyCon :: Boxity -> Arity -> TyCon
228 tupleTyCon boxity i | i > mAX_TUPLE_SIZE = fst (mk_tuple boxity i)      -- Build one specially
229 tupleTyCon Boxed   i = fst (boxedTupleArr   ! i)
230 tupleTyCon Unboxed i = fst (unboxedTupleArr ! i)
231
232 tupleCon :: Boxity -> Arity -> DataCon
233 tupleCon boxity i | i > mAX_TUPLE_SIZE = snd (mk_tuple boxity i)        -- Build one specially
234 tupleCon Boxed   i = snd (boxedTupleArr   ! i)
235 tupleCon Unboxed i = snd (unboxedTupleArr ! i)
236
237 boxedTupleArr, unboxedTupleArr :: Array Int (TyCon,DataCon)
238 boxedTupleArr   = listArray (0,mAX_TUPLE_SIZE) [mk_tuple Boxed i | i <- [0..mAX_TUPLE_SIZE]]
239 unboxedTupleArr = listArray (0,mAX_TUPLE_SIZE) [mk_tuple Unboxed i | i <- [0..mAX_TUPLE_SIZE]]
240
241 mk_tuple :: Boxity -> Int -> (TyCon,DataCon)
242 mk_tuple boxity arity = (tycon, tuple_con)
243   where
244         tycon   = mkTupleTyCon tc_name tc_kind arity tyvars tuple_con boxity gen_info 
245         tc_name = mkWiredInName mod (mkOccFS tcName name_str) tc_uniq
246         tc_kind = mkArrowKinds (map tyVarKind tyvars) res_kind
247         res_kind | isBoxed boxity = liftedTypeKind
248                  | otherwise      = unliftedTypeKind
249
250         tyvars   | isBoxed boxity = take arity alphaTyVars
251                  | otherwise      = take arity openAlphaTyVars
252
253         tuple_con = pcDataCon name tyvars [] tyvar_tys tycon
254         tyvar_tys = mkTyVarTys tyvars
255         (mod_name, name_str) = mkTupNameStr boxity arity
256         name      = mkWiredInName mod (mkOccFS dataName name_str) dc_uniq
257         tc_uniq   = mkTupleTyConUnique   boxity arity
258         dc_uniq   = mkTupleDataConUnique boxity arity
259         mod       = mkBasePkgModule mod_name
260         gen_info  = mk_tc_gen_info mod tc_uniq tc_name tycon
261
262 unitTyCon     = tupleTyCon Boxed 0
263 unitDataCon   = head (tyConDataCons unitTyCon)
264 unitDataConId = dataConWorkId unitDataCon
265
266 pairTyCon = tupleTyCon Boxed 2
267
268 unboxedSingletonTyCon   = tupleTyCon Unboxed 1
269 unboxedSingletonDataCon = tupleCon   Unboxed 1
270
271 unboxedPairTyCon   = tupleTyCon Unboxed 2
272 unboxedPairDataCon = tupleCon   Unboxed 2
273 \end{code}
274
275 %************************************************************************
276 %*                                                                      *
277 \subsection[TysWiredIn-boxed-prim]{The ``boxed primitive'' types (@Char@, @Int@, etc)}
278 %*                                                                      *
279 %************************************************************************
280
281 \begin{code}
282 -- The Void type is represented as a data type with no constructors
283 -- It's a built in type (i.e. there's no way to define it in Haskell;
284 --      the nearest would be
285 --
286 --              data Void =             -- No constructors!
287 --
288 -- ) It's lifted; there is only one value of this
289 -- type, namely "void", whose semantics is just bottom.
290 --
291 -- Haskell 98 drops the definition of a Void type, so we just 'simulate'
292 -- voidTy using ().
293 voidTy = unitTy
294 \end{code}
295
296
297 \begin{code}
298 charTy = mkTyConTy charTyCon
299
300 charTyCon   = pcNonRecDataTyCon charTyConName [] [] [charDataCon]
301 charDataCon = pcDataCon charDataConName [] [] [charPrimTy] charTyCon
302
303 stringTy = mkListTy charTy -- convenience only
304 \end{code}
305
306 \begin{code}
307 intTy = mkTyConTy intTyCon 
308
309 intTyCon = pcNonRecDataTyCon intTyConName [] [] [intDataCon]
310 intDataCon = pcDataCon intDataConName [] [] [intPrimTy] intTyCon
311 \end{code}
312
313 \begin{code}
314 wordTy = mkTyConTy wordTyCon
315
316 wordTyCon = pcNonRecDataTyCon wordTyConName [] [] [wordDataCon]
317 wordDataCon = pcDataCon wordDataConName [] [] [wordPrimTy] wordTyCon
318 \end{code}
319
320 \begin{code}
321 addrTy = mkTyConTy addrTyCon
322
323 addrTyCon = pcNonRecDataTyCon addrTyConName [] [] [addrDataCon]
324 addrDataCon = pcDataCon addrDataConName [] [] [addrPrimTy] addrTyCon
325 \end{code}
326
327 \begin{code}
328 ptrTy = mkTyConTy ptrTyCon
329
330 ptrTyCon = pcNonRecDataTyCon ptrTyConName alpha_tyvar [(True,False)] [ptrDataCon]
331 ptrDataCon = pcDataCon ptrDataConName alpha_tyvar [] [addrPrimTy] ptrTyCon
332 \end{code}
333
334 \begin{code}
335 funPtrTy = mkTyConTy funPtrTyCon
336
337 funPtrTyCon = pcNonRecDataTyCon funPtrTyConName alpha_tyvar [(True,False)] [funPtrDataCon]
338 funPtrDataCon = pcDataCon funPtrDataConName alpha_tyvar [] [addrPrimTy] funPtrTyCon
339 \end{code}
340
341 \begin{code}
342 floatTy = mkTyConTy floatTyCon
343
344 floatTyCon   = pcNonRecDataTyCon floatTyConName   [] [] [floatDataCon]
345 floatDataCon = pcDataCon         floatDataConName [] [] [floatPrimTy] floatTyCon
346 \end{code}
347
348 \begin{code}
349 doubleTy = mkTyConTy doubleTyCon
350
351 doubleTyCon   = pcNonRecDataTyCon doubleTyConName     [] [] [doubleDataCon]
352 doubleDataCon = pcDataCon         doubleDataConName [] [] [doublePrimTy] doubleTyCon
353 \end{code}
354
355 \begin{code}
356 stablePtrTyCon
357   = pcNonRecDataTyCon stablePtrTyConName
358         alpha_tyvar [(True,False)] [stablePtrDataCon]
359   where
360     stablePtrDataCon
361       = pcDataCon stablePtrDataConName
362             alpha_tyvar [] [mkStablePtrPrimTy alphaTy] stablePtrTyCon
363 \end{code}
364
365 %************************************************************************
366 %*                                                                      *
367 \subsection[TysWiredIn-Integer]{@Integer@ and its related ``pairing'' types}
368 %*                                                                      *
369 %************************************************************************
370
371 @Integer@ and its pals are not really primitive.  @Integer@ itself, first:
372 \begin{code}
373 integerTy :: Type
374 integerTy = mkTyConTy integerTyCon
375
376 integerTyCon = pcNonRecDataTyCon integerTyConName
377                    [] [] [smallIntegerDataCon, largeIntegerDataCon]
378
379 smallIntegerDataCon = pcDataCon smallIntegerDataConName
380                 [] [] [intPrimTy] integerTyCon
381 largeIntegerDataCon = pcDataCon largeIntegerDataConName
382                 [] [] [intPrimTy, byteArrayPrimTy] integerTyCon
383 \end{code}
384
385
386 %************************************************************************
387 %*                                                                      *
388 \subsection[TysWiredIn-Bool]{The @Bool@ type}
389 %*                                                                      *
390 %************************************************************************
391
392 An ordinary enumeration type, but deeply wired in.  There are no
393 magical operations on @Bool@ (just the regular Prelude code).
394
395 {\em BEGIN IDLE SPECULATION BY SIMON}
396
397 This is not the only way to encode @Bool@.  A more obvious coding makes
398 @Bool@ just a boxed up version of @Bool#@, like this:
399 \begin{verbatim}
400 type Bool# = Int#
401 data Bool = MkBool Bool#
402 \end{verbatim}
403
404 Unfortunately, this doesn't correspond to what the Report says @Bool@
405 looks like!  Furthermore, we get slightly less efficient code (I
406 think) with this coding. @gtInt@ would look like this:
407
408 \begin{verbatim}
409 gtInt :: Int -> Int -> Bool
410 gtInt x y = case x of I# x# ->
411             case y of I# y# ->
412             case (gtIntPrim x# y#) of
413                 b# -> MkBool b#
414 \end{verbatim}
415
416 Notice that the result of the @gtIntPrim@ comparison has to be turned
417 into an integer (here called @b#@), and returned in a @MkBool@ box.
418
419 The @if@ expression would compile to this:
420 \begin{verbatim}
421 case (gtInt x y) of
422   MkBool b# -> case b# of { 1# -> e1; 0# -> e2 }
423 \end{verbatim}
424
425 I think this code is a little less efficient than the previous code,
426 but I'm not certain.  At all events, corresponding with the Report is
427 important.  The interesting thing is that the language is expressive
428 enough to describe more than one alternative; and that a type doesn't
429 necessarily need to be a straightforwardly boxed version of its
430 primitive counterpart.
431
432 {\em END IDLE SPECULATION BY SIMON}
433
434 \begin{code}
435 boolTy = mkTyConTy boolTyCon
436
437 boolTyCon = pcTyCon EnumTyCon NonRecursive boolTyConName
438                     [] [] [falseDataCon, trueDataCon]
439
440 falseDataCon = pcDataCon falseDataConName [] [] [] boolTyCon
441 trueDataCon  = pcDataCon trueDataConName  [] [] [] boolTyCon
442
443 falseDataConId = dataConWorkId falseDataCon
444 trueDataConId  = dataConWorkId trueDataCon
445 \end{code}
446
447 %************************************************************************
448 %*                                                                      *
449 \subsection[TysWiredIn-List]{The @List@ type (incl ``build'' magic)}
450 %*                                                                      *
451 %************************************************************************
452
453 Special syntax, deeply wired in, but otherwise an ordinary algebraic
454 data types:
455 \begin{verbatim}
456 data [] a = [] | a : (List a)
457 data () = ()
458 data (,) a b = (,,) a b
459 ...
460 \end{verbatim}
461
462 \begin{code}
463 mkListTy :: Type -> Type
464 mkListTy ty = mkTyConApp listTyCon [ty]
465
466 listTyCon = pcRecDataTyCon listTyConName
467                         alpha_tyvar [(True,False)] [nilDataCon, consDataCon]
468
469 nilDataCon  = pcDataCon nilDataConName alpha_tyvar [] [] listTyCon
470 consDataCon = pcDataCon consDataConName
471                alpha_tyvar [] [alphaTy, mkTyConApp listTyCon alpha_ty] listTyCon
472 -- Interesting: polymorphic recursion would help here.
473 -- We can't use (mkListTy alphaTy) in the defn of consDataCon, else mkListTy
474 -- gets the over-specific type (Type -> Type)
475 \end{code}
476
477 %************************************************************************
478 %*                                                                      *
479 \subsection[TysWiredIn-Tuples]{The @Tuple@ types}
480 %*                                                                      *
481 %************************************************************************
482
483 The tuple types are definitely magic, because they form an infinite
484 family.
485
486 \begin{itemize}
487 \item
488 They have a special family of type constructors, of type @TyCon@
489 These contain the tycon arity, but don't require a Unique.
490
491 \item
492 They have a special family of constructors, of type
493 @Id@. Again these contain their arity but don't need a Unique.
494
495 \item
496 There should be a magic way of generating the info tables and
497 entry code for all tuples.
498
499 But at the moment we just compile a Haskell source
500 file\srcloc{lib/prelude/...} containing declarations like:
501 \begin{verbatim}
502 data Tuple0             = Tup0
503 data Tuple2  a b        = Tup2  a b
504 data Tuple3  a b c      = Tup3  a b c
505 data Tuple4  a b c d    = Tup4  a b c d
506 ...
507 \end{verbatim}
508 The print-names associated with the magic @Id@s for tuple constructors
509 ``just happen'' to be the same as those generated by these
510 declarations.
511
512 \item
513 The instance environment should have a magic way to know
514 that each tuple type is an instances of classes @Eq@, @Ix@, @Ord@ and
515 so on. \ToDo{Not implemented yet.}
516
517 \item
518 There should also be a way to generate the appropriate code for each
519 of these instances, but (like the info tables and entry code) it is
520 done by enumeration\srcloc{lib/prelude/InTup?.hs}.
521 \end{itemize}
522
523 \begin{code}
524 mkTupleTy :: Boxity -> Int -> [Type] -> Type
525 mkTupleTy boxity arity tys = mkTyConApp (tupleTyCon boxity arity) tys
526
527 unitTy    = mkTupleTy Boxed 0 []
528 \end{code}
529
530 %************************************************************************
531 %*                                                                      *
532 \subsection[TysWiredIn-PArr]{The @[::]@ type}
533 %*                                                                      *
534 %************************************************************************
535
536 Special syntax for parallel arrays needs some wired in definitions.
537
538 \begin{code}
539 -- construct a type representing the application of the parallel array
540 -- constructor 
541 --
542 mkPArrTy    :: Type -> Type
543 mkPArrTy ty  = mkTyConApp parrTyCon [ty]
544
545 -- represents the type constructor of parallel arrays
546 --
547 -- * this must match the definition in `PrelPArr'
548 --
549 -- NB: Although the constructor is given here, it will not be accessible in
550 --     user code as it is not in the environment of any compiled module except
551 --     `PrelPArr'.
552 --
553 parrTyCon :: TyCon
554 parrTyCon  = tycon
555   where
556     tycon   = mkAlgTyCon 
557                 parrTyConName 
558                 kind
559                 tyvars
560                 []                       -- No context
561                 [(True, False)]
562                 (DataCons [parrDataCon]) -- The constructor defined in `PrelPArr'
563                 []                       -- No record selectors
564                 DataTyCon
565                 NonRecursive
566                 genInfo
567     tyvars  = alpha_tyvar
568     mod     = nameModule parrTyConName
569     kind    = mkArrowKinds (map tyVarKind tyvars) liftedTypeKind
570     genInfo = mk_tc_gen_info mod (nameUnique parrTyConName) parrTyConName tycon
571
572 parrDataCon :: DataCon
573 parrDataCon  = pcDataCon 
574                  parrDataConName 
575                  alpha_tyvar            -- forall'ed type variables
576                  []                     -- context
577                  [intPrimTy,            -- 1st argument: Int#
578                   mkTyConApp            -- 2nd argument: Array# a
579                     arrayPrimTyCon 
580                     alpha_ty] 
581                  parrTyCon
582
583 -- check whether a type constructor is the constructor for parallel arrays
584 --
585 isPArrTyCon    :: TyCon -> Bool
586 isPArrTyCon tc  = tyConName tc == parrTyConName
587
588 -- fake array constructors
589 --
590 -- * these constructors are never really used to represent array values;
591 --   however, they are very convenient during desugaring (and, in particular,
592 --   in the pattern matching compiler) to treat array pattern just like
593 --   yet another constructor pattern
594 --
595 parrFakeCon                        :: Arity -> DataCon
596 parrFakeCon i | i > mAX_TUPLE_SIZE  = mkPArrFakeCon  i  -- build one specially
597 parrFakeCon i                       = parrFakeConArr!i
598
599 -- pre-defined set of constructors
600 --
601 parrFakeConArr :: Array Int DataCon
602 parrFakeConArr  = array (0, mAX_TUPLE_SIZE) [(i, mkPArrFakeCon i)   
603                                             | i <- [0..mAX_TUPLE_SIZE]]
604
605 -- build a fake parallel array constructor for the given arity
606 --
607 mkPArrFakeCon       :: Int -> DataCon
608 mkPArrFakeCon arity  = pcDataCon name [tyvar] [] tyvarTys parrTyCon
609   where
610         tyvar     = head alphaTyVars
611         tyvarTys  = replicate arity $ mkTyVarTy tyvar
612         nameStr   = mkFastString ("MkPArr" ++ show arity)
613         name      = mkWiredInName mod (mkOccFS dataName nameStr) uniq
614         uniq      = mkPArrDataConUnique arity
615         mod       = mkBasePkgModule pREL_PARR_Name
616
617 -- checks whether a data constructor is a fake constructor for parallel arrays
618 --
619 isPArrFakeCon      :: DataCon -> Bool
620 isPArrFakeCon dcon  = dcon == parrFakeCon (dataConSourceArity dcon)
621 \end{code}
622
623 %************************************************************************
624 %*                                                                      *
625 \subsection{Wired In Type Constructors for Representation Types}
626 %*                                                                      *
627 %************************************************************************
628
629 The following code defines the wired in datatypes cross, plus, unit
630 and c_of needed for the generic methods.
631
632 Ok, so the basic story is that for each type constructor I need to
633 create 2 things - a TyCon and a DataCon and then we are basically
634 ok. There are going to be no arguments passed to these functions
635 because -well- there is nothing to pass to these functions.
636
637 \begin{code}
638 crossTyCon :: TyCon
639 crossTyCon = pcNonRecDataTyCon crossTyConName alpha_beta_tyvars [] [crossDataCon]
640
641 crossDataCon :: DataCon
642 crossDataCon = pcDataCon crossDataConName alpha_beta_tyvars [] [alphaTy, betaTy] crossTyCon
643
644 plusTyCon :: TyCon
645 plusTyCon = pcNonRecDataTyCon plusTyConName alpha_beta_tyvars [] [inlDataCon, inrDataCon]
646
647 inlDataCon, inrDataCon :: DataCon
648 inlDataCon = pcDataCon inlDataConName alpha_beta_tyvars [] [alphaTy] plusTyCon
649 inrDataCon = pcDataCon inrDataConName alpha_beta_tyvars [] [betaTy]  plusTyCon
650
651 genUnitTyCon :: TyCon   -- The "1" type constructor for generics
652 genUnitTyCon = pcNonRecDataTyCon genUnitTyConName [] [] [genUnitDataCon]
653
654 genUnitDataCon :: DataCon
655 genUnitDataCon = pcDataCon genUnitDataConName [] [] [] genUnitTyCon
656 \end{code}