e713eb719c182ff772b0c8fc058a4fcefd95c55d
[ghc-hetmet.git] / 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, 
15
16         boolTy, boolTyCon, boolTyCon_RDR, boolTyConName,
17         trueDataCon,  trueDataConId,  true_RDR,
18         falseDataCon, falseDataConId, false_RDR,
19
20         charTyCon, charDataCon, charTyCon_RDR,
21         charTy, stringTy, charTyConName,
22
23         
24         doubleTyCon, doubleDataCon, doubleTy, doubleTyConName, 
25         
26         floatTyCon, floatDataCon, floatTy, floatTyConName,
27
28         intTyCon, intDataCon, intTyCon_RDR, intDataCon_RDR, intTyConName,
29         intTy,
30
31         listTyCon, nilDataCon, consDataCon,
32         listTyCon_RDR, consDataCon_RDR, listTyConName,
33         mkListTy,
34
35         -- tuples
36         mkTupleTy,
37         tupleTyCon, tupleCon, 
38         unitTyCon, unitDataCon, unitDataConId, pairTyCon, 
39         unboxedSingletonTyCon, unboxedSingletonDataCon,
40         unboxedPairTyCon, unboxedPairDataCon,
41
42         unitTy,
43         voidTy,
44
45         -- parallel arrays
46         mkPArrTy,
47         parrTyCon, parrFakeCon, isPArrTyCon, isPArrFakeCon,
48         parrTyCon_RDR, parrTyConName
49     ) where
50
51 #include "HsVersions.h"
52
53 import {-# SOURCE #-} MkId( mkDataConIds )
54
55 -- friends:
56 import PrelNames
57 import TysPrim
58
59 -- others:
60 import Constants        ( mAX_TUPLE_SIZE )
61 import Module           ( Module )
62 import RdrName          ( nameRdrName )
63 import Name             ( Name, BuiltInSyntax(..), nameUnique, nameOccName, 
64                           nameModule, mkWiredInName )
65 import OccName          ( mkOccNameFS, tcName, dataName, mkTupleOcc,
66                           mkDataConWorkerOcc )
67 import DataCon          ( DataCon, mkDataCon, dataConWorkId, dataConSourceArity )
68 import Var              ( TyVar, tyVarKind )
69 import TyCon            ( TyCon, AlgTyConRhs(DataTyCon), tyConDataCons,
70                           mkTupleTyCon, mkAlgTyCon, tyConName )
71
72 import BasicTypes       ( Arity, RecFlag(..), Boxity(..), isBoxed,
73                           StrictnessMark(..) )
74
75 import Type             ( Type, mkTyConTy, mkTyConApp, mkTyVarTy, mkTyVarTys,
76                           TyThing(..) )
77 import Coercion         ( unsafeCoercionTyCon, symCoercionTyCon,
78                           transCoercionTyCon, leftCoercionTyCon, 
79                           rightCoercionTyCon, instCoercionTyCon )
80 import TypeRep          ( mkArrowKinds, liftedTypeKind, ubxTupleKind )
81 import Unique           ( incrUnique, mkTupleTyConUnique,
82                           mkTupleDataConUnique, mkPArrDataConUnique )
83 import Array
84 import FastString
85 import Outputable
86
87 alpha_tyvar = [alphaTyVar]
88 alpha_ty    = [alphaTy]
89 \end{code}
90
91
92 %************************************************************************
93 %*                                                                      *
94 \subsection{Wired in type constructors}
95 %*                                                                      *
96 %************************************************************************
97
98 If you change which things are wired in, make sure you change their
99 names in PrelNames, so they use wTcQual, wDataQual, etc
100
101 \begin{code}
102 wiredInTyCons :: [TyCon]        -- Excludes tuples
103 -- This list is used only to define PrelInfo.wiredInThings
104
105 -- It does not need to include kind constructors, because
106 -- all that wiredInThings does is to initialise the Name table,
107 -- and kind constructors don't appear in source code.
108
109 wiredInTyCons = [ unitTyCon     -- Not treated like other tuples, because
110                                 -- it's defined in GHC.Base, and there's only
111                                 -- one of it.  We put it in wiredInTyCons so
112                                 -- that it'll pre-populate the name cache, so
113                                 -- the special case in lookupOrigNameCache 
114                                 -- doesn't need to look out for it
115               , boolTyCon
116               , charTyCon
117               , doubleTyCon
118               , floatTyCon
119               , intTyCon
120               , listTyCon
121               , parrTyCon
122               , unsafeCoercionTyCon
123               , symCoercionTyCon
124               , transCoercionTyCon
125               , leftCoercionTyCon
126               , rightCoercionTyCon
127               , instCoercionTyCon
128               ]
129 \end{code}
130
131 \begin{code}
132 mkWiredInTyConName :: BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
133 mkWiredInTyConName built_in mod fs uniq tycon
134   = mkWiredInName mod (mkOccNameFS tcName fs) uniq
135                   Nothing               -- No parent object
136                   (ATyCon tycon)        -- Relevant TyCon
137                   built_in
138
139 mkWiredInDataConName :: BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name -> Name
140 mkWiredInDataConName built_in mod fs uniq datacon parent
141   = mkWiredInName mod (mkOccNameFS dataName fs) uniq
142                   (Just parent)         -- Name of parent TyCon
143                   (ADataCon datacon)    -- Relevant DataCon
144                   built_in
145
146 charTyConName     = mkWiredInTyConName   UserSyntax gHC_BASE FSLIT("Char") charTyConKey charTyCon
147 charDataConName   = mkWiredInDataConName UserSyntax gHC_BASE FSLIT("C#") charDataConKey charDataCon charTyConName
148 intTyConName      = mkWiredInTyConName   UserSyntax gHC_BASE FSLIT("Int") intTyConKey   intTyCon
149 intDataConName    = mkWiredInDataConName UserSyntax gHC_BASE FSLIT("I#") intDataConKey  intDataCon intTyConName
150                                                   
151 boolTyConName     = mkWiredInTyConName   UserSyntax gHC_BASE FSLIT("Bool") boolTyConKey boolTyCon
152 falseDataConName  = mkWiredInDataConName UserSyntax gHC_BASE FSLIT("False") falseDataConKey falseDataCon boolTyConName
153 trueDataConName   = mkWiredInDataConName UserSyntax gHC_BASE FSLIT("True")  trueDataConKey  trueDataCon  boolTyConName
154 listTyConName     = mkWiredInTyConName   BuiltInSyntax gHC_BASE FSLIT("[]") listTyConKey listTyCon
155 nilDataConName    = mkWiredInDataConName BuiltInSyntax gHC_BASE FSLIT("[]") nilDataConKey nilDataCon  listTyConName
156 consDataConName   = mkWiredInDataConName BuiltInSyntax gHC_BASE FSLIT(":") consDataConKey consDataCon listTyConName
157
158 floatTyConName     = mkWiredInTyConName   UserSyntax gHC_FLOAT FSLIT("Float") floatTyConKey floatTyCon
159 floatDataConName   = mkWiredInDataConName UserSyntax gHC_FLOAT FSLIT("F#") floatDataConKey floatDataCon floatTyConName
160 doubleTyConName    = mkWiredInTyConName   UserSyntax gHC_FLOAT FSLIT("Double") doubleTyConKey doubleTyCon
161 doubleDataConName  = mkWiredInDataConName UserSyntax gHC_FLOAT FSLIT("D#") doubleDataConKey doubleDataCon doubleTyConName
162
163 parrTyConName     = mkWiredInTyConName   BuiltInSyntax gHC_PARR FSLIT("[::]") parrTyConKey parrTyCon 
164 parrDataConName   = mkWiredInDataConName UserSyntax    gHC_PARR FSLIT("PArr") parrDataConKey parrDataCon parrTyConName
165
166 boolTyCon_RDR   = nameRdrName boolTyConName
167 false_RDR       = nameRdrName falseDataConName
168 true_RDR        = nameRdrName trueDataConName
169 intTyCon_RDR    = nameRdrName intTyConName
170 charTyCon_RDR   = nameRdrName charTyConName
171 intDataCon_RDR  = nameRdrName intDataConName
172 listTyCon_RDR   = nameRdrName listTyConName
173 consDataCon_RDR = nameRdrName consDataConName
174 parrTyCon_RDR   = nameRdrName parrTyConName
175 {-
176 tySuperKindTyCon_RDR     = nameRdrName tySuperKindTyConName
177 coSuperKindTyCon_RDR = nameRdrName coSuperKindTyConName
178 liftedTypeKindTyCon_RDR   = nameRdrName liftedTypeKindTyConName
179 openTypeKindTyCon_RDR     = nameRdrName openTypeKindTyConName
180 unliftedTypeKindTyCon_RDR = nameRdrName unliftedTypeKindTyConName
181 ubxTupleKindTyCon_RDR     = nameRdrName ubxTupleKindTyConName
182 argTypeKindTyCon_RDR      = nameRdrName argTypeKindTyConName
183 funKindTyCon_RDR          = nameRdrName funKindTyConName
184 -}
185 \end{code}
186
187
188 %************************************************************************
189 %*                                                                      *
190 \subsection{mkWiredInTyCon}
191 %*                                                                      *
192 %************************************************************************
193
194 \begin{code}
195 pcNonRecDataTyCon = pcTyCon False NonRecursive
196 pcRecDataTyCon    = pcTyCon False Recursive
197
198 pcTyCon is_enum is_rec name tyvars cons
199   = tycon
200   where
201     tycon = mkAlgTyCon name
202                 (mkArrowKinds (map tyVarKind tyvars) liftedTypeKind)
203                 tyvars
204                 []              -- No stupid theta
205                 (DataTyCon cons is_enum)
206                 []              -- No record selectors
207                 is_rec
208                 True            -- All the wired-in tycons have generics
209                 False           -- Not in GADT syntax
210
211 pcDataCon :: Name -> [TyVar] -> [Type] -> TyCon -> DataCon
212 pcDataCon = pcDataConWithFixity False
213
214 pcDataConWithFixity :: Bool -> Name -> [TyVar] -> [Type] -> TyCon -> DataCon
215 -- The Name should be in the DataName name space; it's the name
216 -- of the DataCon itself.
217 --
218 -- The unique is the first of two free uniques;
219 -- the first is used for the datacon itself,
220 -- the second is used for the "worker name"
221
222 pcDataConWithFixity declared_infix dc_name tyvars arg_tys tycon
223   = data_con
224   where
225     data_con = mkDataCon dc_name declared_infix
226                 (map (const NotMarkedStrict) arg_tys)
227                 []      -- No labelled fields
228                 tyvars
229                 []      -- No existential type variables
230                 []      -- No equality spec
231                 []      -- No theta
232                 arg_tys tycon
233                 []      -- No stupid theta
234                 (mkDataConIds bogus_wrap_name wrk_name data_con)
235                 
236
237     mod      = nameModule dc_name
238     wrk_occ  = mkDataConWorkerOcc (nameOccName dc_name)
239     wrk_key  = incrUnique (nameUnique dc_name)
240     wrk_name = mkWiredInName mod wrk_occ wrk_key
241                              (Just (tyConName tycon))
242                              (AnId (dataConWorkId data_con)) UserSyntax
243     bogus_wrap_name = pprPanic "Wired-in data wrapper id" (ppr dc_name)
244         -- Wired-in types are too simple to need wrappers
245 \end{code}
246
247
248 %************************************************************************
249 %*                                                                      *
250 \subsection[TysWiredIn-tuples]{The tuple types}
251 %*                                                                      *
252 %************************************************************************
253
254 \begin{code}
255 tupleTyCon :: Boxity -> Arity -> TyCon
256 tupleTyCon boxity i | i > mAX_TUPLE_SIZE = fst (mk_tuple boxity i)      -- Build one specially
257 tupleTyCon Boxed   i = fst (boxedTupleArr   ! i)
258 tupleTyCon Unboxed i = fst (unboxedTupleArr ! i)
259
260 tupleCon :: Boxity -> Arity -> DataCon
261 tupleCon boxity i | i > mAX_TUPLE_SIZE = snd (mk_tuple boxity i)        -- Build one specially
262 tupleCon Boxed   i = snd (boxedTupleArr   ! i)
263 tupleCon Unboxed i = snd (unboxedTupleArr ! i)
264
265 boxedTupleArr, unboxedTupleArr :: Array Int (TyCon,DataCon)
266 boxedTupleArr   = listArray (0,mAX_TUPLE_SIZE) [mk_tuple Boxed i | i <- [0..mAX_TUPLE_SIZE]]
267 unboxedTupleArr = listArray (0,mAX_TUPLE_SIZE) [mk_tuple Unboxed i | i <- [0..mAX_TUPLE_SIZE]]
268
269 mk_tuple :: Boxity -> Int -> (TyCon,DataCon)
270 mk_tuple boxity arity = (tycon, tuple_con)
271   where
272         tycon   = mkTupleTyCon tc_name tc_kind arity tyvars tuple_con boxity gen_info 
273         mod     = mkTupleModule boxity arity
274         tc_name = mkWiredInName mod (mkTupleOcc tcName boxity arity) tc_uniq
275                                 Nothing (ATyCon tycon) BuiltInSyntax
276         tc_kind = mkArrowKinds (map tyVarKind tyvars) res_kind
277         res_kind | isBoxed boxity = liftedTypeKind
278                  | otherwise      = ubxTupleKind
279
280         tyvars   | isBoxed boxity = take arity alphaTyVars
281                  | otherwise      = take arity openAlphaTyVars
282
283         tuple_con = pcDataCon dc_name tyvars tyvar_tys tycon
284         tyvar_tys = mkTyVarTys tyvars
285         dc_name   = mkWiredInName mod (mkTupleOcc dataName boxity arity) dc_uniq
286                                   (Just tc_name) (ADataCon tuple_con) BuiltInSyntax
287         tc_uniq   = mkTupleTyConUnique   boxity arity
288         dc_uniq   = mkTupleDataConUnique boxity arity
289         gen_info  = True                -- Tuples all have generics..
290                                         -- hmm: that's a *lot* of code
291
292 unitTyCon     = tupleTyCon Boxed 0
293 unitDataCon   = head (tyConDataCons unitTyCon)
294 unitDataConId = dataConWorkId unitDataCon
295
296 pairTyCon = tupleTyCon Boxed 2
297
298 unboxedSingletonTyCon   = tupleTyCon Unboxed 1
299 unboxedSingletonDataCon = tupleCon   Unboxed 1
300
301 unboxedPairTyCon   = tupleTyCon Unboxed 2
302 unboxedPairDataCon = tupleCon   Unboxed 2
303 \end{code}
304
305 %************************************************************************
306 %*                                                                      *
307 \subsection[TysWiredIn-boxed-prim]{The ``boxed primitive'' types (@Char@, @Int@, etc)}
308 %*                                                                      *
309 %************************************************************************
310
311 \begin{code}
312 -- The Void type is represented as a data type with no constructors
313 -- It's a built in type (i.e. there's no way to define it in Haskell;
314 --      the nearest would be
315 --
316 --              data Void =             -- No constructors!
317 --
318 -- ) It's lifted; there is only one value of this
319 -- type, namely "void", whose semantics is just bottom.
320 --
321 -- Haskell 98 drops the definition of a Void type, so we just 'simulate'
322 -- voidTy using ().
323 voidTy = unitTy
324 \end{code}
325
326
327 \begin{code}
328 charTy = mkTyConTy charTyCon
329
330 charTyCon   = pcNonRecDataTyCon charTyConName [] [charDataCon]
331 charDataCon = pcDataCon charDataConName [] [charPrimTy] charTyCon
332
333 stringTy = mkListTy charTy -- convenience only
334 \end{code}
335
336 \begin{code}
337 intTy = mkTyConTy intTyCon 
338
339 intTyCon = pcNonRecDataTyCon intTyConName [] [intDataCon]
340 intDataCon = pcDataCon intDataConName [] [intPrimTy] intTyCon
341 \end{code}
342
343 \begin{code}
344 floatTy = mkTyConTy floatTyCon
345
346 floatTyCon   = pcNonRecDataTyCon floatTyConName   [] [floatDataCon]
347 floatDataCon = pcDataCon         floatDataConName [] [floatPrimTy] floatTyCon
348 \end{code}
349
350 \begin{code}
351 doubleTy = mkTyConTy doubleTyCon
352
353 doubleTyCon   = pcNonRecDataTyCon doubleTyConName   [] [doubleDataCon]
354 doubleDataCon = pcDataCon         doubleDataConName [] [doublePrimTy] doubleTyCon
355 \end{code}
356
357
358 %************************************************************************
359 %*                                                                      *
360 \subsection[TysWiredIn-Bool]{The @Bool@ type}
361 %*                                                                      *
362 %************************************************************************
363
364 An ordinary enumeration type, but deeply wired in.  There are no
365 magical operations on @Bool@ (just the regular Prelude code).
366
367 {\em BEGIN IDLE SPECULATION BY SIMON}
368
369 This is not the only way to encode @Bool@.  A more obvious coding makes
370 @Bool@ just a boxed up version of @Bool#@, like this:
371 \begin{verbatim}
372 type Bool# = Int#
373 data Bool = MkBool Bool#
374 \end{verbatim}
375
376 Unfortunately, this doesn't correspond to what the Report says @Bool@
377 looks like!  Furthermore, we get slightly less efficient code (I
378 think) with this coding. @gtInt@ would look like this:
379
380 \begin{verbatim}
381 gtInt :: Int -> Int -> Bool
382 gtInt x y = case x of I# x# ->
383             case y of I# y# ->
384             case (gtIntPrim x# y#) of
385                 b# -> MkBool b#
386 \end{verbatim}
387
388 Notice that the result of the @gtIntPrim@ comparison has to be turned
389 into an integer (here called @b#@), and returned in a @MkBool@ box.
390
391 The @if@ expression would compile to this:
392 \begin{verbatim}
393 case (gtInt x y) of
394   MkBool b# -> case b# of { 1# -> e1; 0# -> e2 }
395 \end{verbatim}
396
397 I think this code is a little less efficient than the previous code,
398 but I'm not certain.  At all events, corresponding with the Report is
399 important.  The interesting thing is that the language is expressive
400 enough to describe more than one alternative; and that a type doesn't
401 necessarily need to be a straightforwardly boxed version of its
402 primitive counterpart.
403
404 {\em END IDLE SPECULATION BY SIMON}
405
406 \begin{code}
407 boolTy = mkTyConTy boolTyCon
408
409 boolTyCon = pcTyCon True NonRecursive boolTyConName
410                     [] [falseDataCon, trueDataCon]
411
412 falseDataCon = pcDataCon falseDataConName [] [] boolTyCon
413 trueDataCon  = pcDataCon trueDataConName  [] [] boolTyCon
414
415 falseDataConId = dataConWorkId falseDataCon
416 trueDataConId  = dataConWorkId trueDataCon
417 \end{code}
418
419 %************************************************************************
420 %*                                                                      *
421 \subsection[TysWiredIn-List]{The @List@ type (incl ``build'' magic)}
422 %*                                                                      *
423 %************************************************************************
424
425 Special syntax, deeply wired in, but otherwise an ordinary algebraic
426 data types:
427 \begin{verbatim}
428 data [] a = [] | a : (List a)
429 data () = ()
430 data (,) a b = (,,) a b
431 ...
432 \end{verbatim}
433
434 \begin{code}
435 mkListTy :: Type -> Type
436 mkListTy ty = mkTyConApp listTyCon [ty]
437
438 listTyCon = pcRecDataTyCon listTyConName alpha_tyvar [nilDataCon, consDataCon]
439
440 nilDataCon  = pcDataCon nilDataConName alpha_tyvar [] listTyCon
441 consDataCon = pcDataConWithFixity True {- Declared infix -}
442                consDataConName
443                alpha_tyvar [alphaTy, mkTyConApp listTyCon alpha_ty] listTyCon
444 -- Interesting: polymorphic recursion would help here.
445 -- We can't use (mkListTy alphaTy) in the defn of consDataCon, else mkListTy
446 -- gets the over-specific type (Type -> Type)
447 \end{code}
448
449 %************************************************************************
450 %*                                                                      *
451 \subsection[TysWiredIn-Tuples]{The @Tuple@ types}
452 %*                                                                      *
453 %************************************************************************
454
455 The tuple types are definitely magic, because they form an infinite
456 family.
457
458 \begin{itemize}
459 \item
460 They have a special family of type constructors, of type @TyCon@
461 These contain the tycon arity, but don't require a Unique.
462
463 \item
464 They have a special family of constructors, of type
465 @Id@. Again these contain their arity but don't need a Unique.
466
467 \item
468 There should be a magic way of generating the info tables and
469 entry code for all tuples.
470
471 But at the moment we just compile a Haskell source
472 file\srcloc{lib/prelude/...} containing declarations like:
473 \begin{verbatim}
474 data Tuple0             = Tup0
475 data Tuple2  a b        = Tup2  a b
476 data Tuple3  a b c      = Tup3  a b c
477 data Tuple4  a b c d    = Tup4  a b c d
478 ...
479 \end{verbatim}
480 The print-names associated with the magic @Id@s for tuple constructors
481 ``just happen'' to be the same as those generated by these
482 declarations.
483
484 \item
485 The instance environment should have a magic way to know
486 that each tuple type is an instances of classes @Eq@, @Ix@, @Ord@ and
487 so on. \ToDo{Not implemented yet.}
488
489 \item
490 There should also be a way to generate the appropriate code for each
491 of these instances, but (like the info tables and entry code) it is
492 done by enumeration\srcloc{lib/prelude/InTup?.hs}.
493 \end{itemize}
494
495 \begin{code}
496 mkTupleTy :: Boxity -> Int -> [Type] -> Type
497 mkTupleTy boxity arity tys = mkTyConApp (tupleTyCon boxity arity) tys
498
499 unitTy    = mkTupleTy Boxed 0 []
500 \end{code}
501
502 %************************************************************************
503 %*                                                                      *
504 \subsection[TysWiredIn-PArr]{The @[::]@ type}
505 %*                                                                      *
506 %************************************************************************
507
508 Special syntax for parallel arrays needs some wired in definitions.
509
510 \begin{code}
511 -- construct a type representing the application of the parallel array
512 -- constructor 
513 --
514 mkPArrTy    :: Type -> Type
515 mkPArrTy ty  = mkTyConApp parrTyCon [ty]
516
517 -- represents the type constructor of parallel arrays
518 --
519 --  * this must match the definition in `PrelPArr'
520 --
521 -- NB: Although the constructor is given here, it will not be accessible in
522 --     user code as it is not in the environment of any compiled module except
523 --     `PrelPArr'.
524 --
525 parrTyCon :: TyCon
526 parrTyCon  = pcNonRecDataTyCon parrTyConName alpha_tyvar [parrDataCon]
527
528 parrDataCon :: DataCon
529 parrDataCon  = pcDataCon 
530                  parrDataConName 
531                  alpha_tyvar            -- forall'ed type variables
532                  [intPrimTy,            -- 1st argument: Int#
533                   mkTyConApp            -- 2nd argument: Array# a
534                     arrayPrimTyCon 
535                     alpha_ty] 
536                  parrTyCon
537
538 -- check whether a type constructor is the constructor for parallel arrays
539 --
540 isPArrTyCon    :: TyCon -> Bool
541 isPArrTyCon tc  = tyConName tc == parrTyConName
542
543 -- fake array constructors
544 --
545 --  * these constructors are never really used to represent array values;
546 --   however, they are very convenient during desugaring (and, in particular,
547 --   in the pattern matching compiler) to treat array pattern just like
548 --   yet another constructor pattern
549 --
550 parrFakeCon                        :: Arity -> DataCon
551 parrFakeCon i | i > mAX_TUPLE_SIZE  = mkPArrFakeCon  i  -- build one specially
552 parrFakeCon i                       = parrFakeConArr!i
553
554 -- pre-defined set of constructors
555 --
556 parrFakeConArr :: Array Int DataCon
557 parrFakeConArr  = array (0, mAX_TUPLE_SIZE) [(i, mkPArrFakeCon i)   
558                                             | i <- [0..mAX_TUPLE_SIZE]]
559
560 -- build a fake parallel array constructor for the given arity
561 --
562 mkPArrFakeCon       :: Int -> DataCon
563 mkPArrFakeCon arity  = data_con
564   where
565         data_con  = pcDataCon name [tyvar] tyvarTys parrTyCon
566         tyvar     = head alphaTyVars
567         tyvarTys  = replicate arity $ mkTyVarTy tyvar
568         nameStr   = mkFastString ("MkPArr" ++ show arity)
569         name      = mkWiredInName gHC_PARR (mkOccNameFS dataName nameStr) uniq
570                                   Nothing (ADataCon data_con) UserSyntax
571         uniq      = mkPArrDataConUnique arity
572
573 -- checks whether a data constructor is a fake constructor for parallel arrays
574 --
575 isPArrFakeCon      :: DataCon -> Bool
576 isPArrFakeCon dcon  = dcon == parrFakeCon (dataConSourceArity dcon)
577 \end{code}
578
579