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