TysWiredIn.lhs 19 KB
Newer Older
1
%
2
% (c) The GRASP Project, Glasgow University, 1994-1998
3 4 5 6 7 8 9 10 11 12 13
%
\section[TysWiredIn]{Wired-in knowledge about {\em non-primitive} types}

This module is about types that can be defined in Haskell, but which
must be wired into the compiler nonetheless.

This module tracks the ``state interface'' document, ``GHC prelude:
types and operations.''

\begin{code}
module TysWiredIn (
14 15 16 17 18 19 20 21
	wiredInTyCons, 

	boolTy,	boolTyCon, boolTyCon_RDR, boolTyConName,
	trueDataCon,  trueDataConId,  true_RDR,
	falseDataCon, falseDataConId, false_RDR,

	charTyCon, charDataCon, charTyCon_RDR,
	charTy, stringTy, charTyConName,
sof's avatar
sof committed
22

23
	
24
	doubleTyCon, doubleDataCon, doubleTy, doubleTyConName, 
25
	
26
	floatTyCon, floatDataCon, floatTy, floatTyConName,
sof's avatar
sof committed
27

28 29
	intTyCon, intDataCon, intTyCon_RDR, intDataCon_RDR, intTyConName,
	intTy,
30

31 32
	listTyCon, nilDataCon, consDataCon,
	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
       
        boxedTupleArr, unboxedTupleArr,
43

44
	unitTy,
chak's avatar
chak committed
45 46 47

        -- parallel arrays
	mkPArrTy,
48 49
	parrTyCon, parrFakeCon, isPArrTyCon, isPArrFakeCon,
	parrTyCon_RDR, parrTyConName
50 51
    ) where

52 53
#include "HsVersions.h"

54
import {-# SOURCE #-} MkId( mkDataConIds )
55

56
-- friends:
57
import PrelNames
58 59
import TysPrim

60
-- others:
61
import Constants	( mAX_TUPLE_SIZE )
62 63
import Module		( Module )
import RdrName		( nameRdrName )
64
import Name		( Name, BuiltInSyntax(..), nameUnique, nameOccName, 
65
			  nameModule, mkWiredInName )
66 67
import OccName		( mkOccNameFS, tcName, dataName, mkTupleOcc,
			  mkDataConWorkerOcc )
68
import DataCon		( DataCon, mkDataCon, dataConWorkId, dataConSourceArity )
69
import Var		( TyVar, tyVarKind )
70
import TyCon		( TyCon, AlgTyConRhs(DataTyCon), tyConDataCons,
71
			  mkTupleTyCon, mkAlgTyCon, tyConName,
72
			  TyConParent(NoParentTyCon) )
73

74 75
import BasicTypes	( Arity, RecFlag(..), Boxity(..), isBoxed,
			  StrictnessMark(..) )
76

77 78
import Type		( Type, mkTyConTy, mkTyConApp, mkTyVarTy, mkTyVarTys,
			  TyThing(..) )
79 80 81 82
import Coercion         ( unsafeCoercionTyCon, symCoercionTyCon,
                          transCoercionTyCon, leftCoercionTyCon, 
                          rightCoercionTyCon, instCoercionTyCon )
import TypeRep          ( mkArrowKinds, liftedTypeKind, ubxTupleKind )
chak's avatar
chak committed
83 84
import Unique		( incrUnique, mkTupleTyConUnique,
			  mkTupleDataConUnique, mkPArrDataConUnique )
85
import Array
86
import FastString
87
import Outputable
sof's avatar
sof committed
88

89 90
alpha_tyvar = [alphaTyVar]
alpha_ty    = [alphaTy]
91
\end{code}
92 93


94 95 96 97 98
%************************************************************************
%*									*
\subsection{Wired in type constructors}
%*									*
%************************************************************************
99

100 101 102
If you change which things are wired in, make sure you change their
names in PrelNames, so they use wTcQual, wDataQual, etc

103
\begin{code}
104
wiredInTyCons :: [TyCon]	-- Excludes tuples
105 106 107 108 109 110
-- This list is used only to define PrelInfo.wiredInThings

-- It does not need to include kind constructors, because
-- all that wiredInThings does is to initialise the Name table,
-- and kind constructors don't appear in source code.

111 112 113 114 115 116 117
wiredInTyCons = [ unitTyCon	-- Not treated like other tuples, because
				-- it's defined in GHC.Base, and there's only
				-- one of it.  We put it in wiredInTyCons so
				-- that it'll pre-populate the name cache, so
				-- the special case in lookupOrigNameCache 
				-- doesn't need to look out for it
	      , boolTyCon
118 119 120 121 122
    	      , charTyCon
    	      , doubleTyCon
    	      , floatTyCon
    	      , intTyCon
    	      , listTyCon
chak's avatar
chak committed
123
	      , parrTyCon
124 125 126 127 128 129
              , unsafeCoercionTyCon
              , symCoercionTyCon
              , transCoercionTyCon
              , leftCoercionTyCon
              , rightCoercionTyCon
              , instCoercionTyCon
130
    	      ]
131
\end{code}
132

133
\begin{code}
134 135
mkWiredInTyConName :: BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName built_in mod fs uniq tycon
136
  = mkWiredInName mod (mkOccNameFS tcName fs) uniq
137
		  (ATyCon tycon)	-- Relevant TyCon
138
		  built_in
139

140 141
mkWiredInDataConName :: BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName built_in mod fs uniq datacon
142
  = mkWiredInName mod (mkOccNameFS dataName fs) uniq
143
		  (ADataCon datacon)	-- Relevant DataCon
144
		  built_in
145

Simon Marlow's avatar
Simon Marlow committed
146
charTyConName	  = mkWiredInTyConName   UserSyntax gHC_BASE FSLIT("Char") charTyConKey charTyCon
147
charDataConName   = mkWiredInDataConName UserSyntax gHC_BASE FSLIT("C#") charDataConKey charDataCon
Simon Marlow's avatar
Simon Marlow committed
148
intTyConName	  = mkWiredInTyConName   UserSyntax gHC_BASE FSLIT("Int") intTyConKey   intTyCon
149
intDataConName	  = mkWiredInDataConName UserSyntax gHC_BASE FSLIT("I#") intDataConKey  intDataCon
150
						  
Simon Marlow's avatar
Simon Marlow committed
151
boolTyConName	  = mkWiredInTyConName   UserSyntax gHC_BASE FSLIT("Bool") boolTyConKey boolTyCon
152 153
falseDataConName  = mkWiredInDataConName UserSyntax gHC_BASE FSLIT("False") falseDataConKey falseDataCon
trueDataConName	  = mkWiredInDataConName UserSyntax gHC_BASE FSLIT("True")  trueDataConKey  trueDataCon 
Simon Marlow's avatar
Simon Marlow committed
154
listTyConName	  = mkWiredInTyConName   BuiltInSyntax gHC_BASE FSLIT("[]") listTyConKey listTyCon
155 156
nilDataConName 	  = mkWiredInDataConName BuiltInSyntax gHC_BASE FSLIT("[]") nilDataConKey nilDataCon 
consDataConName	  = mkWiredInDataConName BuiltInSyntax gHC_BASE FSLIT(":") consDataConKey consDataCon
157

Simon Marlow's avatar
Simon Marlow committed
158
floatTyConName	   = mkWiredInTyConName   UserSyntax gHC_FLOAT FSLIT("Float") floatTyConKey floatTyCon
159
floatDataConName   = mkWiredInDataConName UserSyntax gHC_FLOAT FSLIT("F#") floatDataConKey floatDataCon
Simon Marlow's avatar
Simon Marlow committed
160
doubleTyConName    = mkWiredInTyConName   UserSyntax gHC_FLOAT FSLIT("Double") doubleTyConKey doubleTyCon
161
doubleDataConName  = mkWiredInDataConName UserSyntax gHC_FLOAT FSLIT("D#") doubleDataConKey doubleDataCon
162

Simon Marlow's avatar
Simon Marlow committed
163
parrTyConName	  = mkWiredInTyConName   BuiltInSyntax gHC_PARR FSLIT("[::]") parrTyConKey parrTyCon 
164
parrDataConName   = mkWiredInDataConName UserSyntax    gHC_PARR FSLIT("PArr") parrDataConKey parrDataCon
165 166 167 168 169 170 171 172 173 174

boolTyCon_RDR   = nameRdrName boolTyConName
false_RDR	= nameRdrName falseDataConName
true_RDR	= nameRdrName trueDataConName
intTyCon_RDR	= nameRdrName intTyConName
charTyCon_RDR	= nameRdrName charTyConName
intDataCon_RDR	= nameRdrName intDataConName
listTyCon_RDR	= nameRdrName listTyConName
consDataCon_RDR = nameRdrName consDataConName
parrTyCon_RDR	= nameRdrName parrTyConName
175 176 177 178 179 180 181 182 183 184
{-
tySuperKindTyCon_RDR     = nameRdrName tySuperKindTyConName
coSuperKindTyCon_RDR = nameRdrName coSuperKindTyConName
liftedTypeKindTyCon_RDR   = nameRdrName liftedTypeKindTyConName
openTypeKindTyCon_RDR     = nameRdrName openTypeKindTyConName
unliftedTypeKindTyCon_RDR = nameRdrName unliftedTypeKindTyConName
ubxTupleKindTyCon_RDR     = nameRdrName ubxTupleKindTyConName
argTypeKindTyCon_RDR      = nameRdrName argTypeKindTyConName
funKindTyCon_RDR          = nameRdrName funKindTyConName
-}
185
\end{code}
186

187

188 189 190 191 192 193 194
%************************************************************************
%*                                                                      *
\subsection{mkWiredInTyCon}
%*                                                                      *
%************************************************************************

\begin{code}
195 196
pcNonRecDataTyCon = pcTyCon False NonRecursive
pcRecDataTyCon    = pcTyCon False Recursive
197

198
pcTyCon is_enum is_rec name tyvars cons
199 200
  = tycon
  where
201 202
    tycon = mkAlgTyCon name
		(mkArrowKinds (map tyVarKind tyvars) liftedTypeKind)
203
                tyvars
204 205
                []		-- No stupid theta
		(DataTyCon cons is_enum)
206
		[] 		-- No record selectors
207
		NoParentTyCon
208
                is_rec
209
		True		-- All the wired-in tycons have generics
210
		False		-- Not in GADT syntax
211

212 213 214 215
pcDataCon :: Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon = pcDataConWithFixity False

pcDataConWithFixity :: Bool -> Name -> [TyVar] -> [Type] -> TyCon -> DataCon
216 217 218
-- The Name should be in the DataName name space; it's the name
-- of the DataCon itself.
--
219
-- The unique is the first of two free uniques;
220 221
-- the first is used for the datacon itself,
-- the second is used for the "worker name"
222

223
pcDataConWithFixity declared_infix dc_name tyvars arg_tys tycon
224 225
  = data_con
  where
226
    data_con = mkDataCon dc_name declared_infix
227
                (map (const NotMarkedStrict) arg_tys)
228 229 230 231 232 233 234
                [] 	-- No labelled fields
                tyvars
		[] 	-- No existential type variables
		[]	-- No equality spec
		[]	-- No theta
		arg_tys tycon
		[]	-- No stupid theta
235
		(mkDataConIds bogus_wrap_name wrk_name data_con)
236
		
237 238 239 240 241

    mod      = nameModule dc_name
    wrk_occ  = mkDataConWorkerOcc (nameOccName dc_name)
    wrk_key  = incrUnique (nameUnique dc_name)
    wrk_name = mkWiredInName mod wrk_occ wrk_key
242
			     (AnId (dataConWorkId data_con)) UserSyntax
243 244
    bogus_wrap_name = pprPanic "Wired-in data wrapper id" (ppr dc_name)
	-- Wired-in types are too simple to need wrappers
245 246
\end{code}

247

248 249 250 251 252 253 254
%************************************************************************
%*									*
\subsection[TysWiredIn-tuples]{The tuple types}
%*									*
%************************************************************************

\begin{code}
255 256 257 258 259 260 261 262 263 264 265
tupleTyCon :: Boxity -> Arity -> TyCon
tupleTyCon boxity i | i > mAX_TUPLE_SIZE = fst (mk_tuple boxity i)	-- Build one specially
tupleTyCon Boxed   i = fst (boxedTupleArr   ! i)
tupleTyCon Unboxed i = fst (unboxedTupleArr ! i)

tupleCon :: Boxity -> Arity -> DataCon
tupleCon boxity i | i > mAX_TUPLE_SIZE = snd (mk_tuple boxity i)	-- Build one specially
tupleCon Boxed   i = snd (boxedTupleArr   ! i)
tupleCon Unboxed i = snd (unboxedTupleArr ! i)

boxedTupleArr, unboxedTupleArr :: Array Int (TyCon,DataCon)
266 267
boxedTupleArr   = listArray (0,mAX_TUPLE_SIZE) [mk_tuple Boxed i | i <- [0..mAX_TUPLE_SIZE]]
unboxedTupleArr = listArray (0,mAX_TUPLE_SIZE) [mk_tuple Unboxed i | i <- [0..mAX_TUPLE_SIZE]]
268 269 270

mk_tuple :: Boxity -> Int -> (TyCon,DataCon)
mk_tuple boxity arity = (tycon, tuple_con)
271
  where
272
	tycon   = mkTupleTyCon tc_name tc_kind arity tyvars tuple_con boxity gen_info 
273 274
	mod	= mkTupleModule boxity arity
	tc_name = mkWiredInName mod (mkTupleOcc tcName boxity arity) tc_uniq
275
				(ATyCon tycon) BuiltInSyntax
276
    	tc_kind = mkArrowKinds (map tyVarKind tyvars) res_kind
277
	res_kind | isBoxed boxity = liftedTypeKind
278
		 | otherwise	  = ubxTupleKind
279 280 281

	tyvars   | isBoxed boxity = take arity alphaTyVars
		 | 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
				  (ADataCon tuple_con) BuiltInSyntax
287 288
 	tc_uniq   = mkTupleTyConUnique   boxity arity
	dc_uniq   = mkTupleDataConUnique boxity arity
289 290
	gen_info  = True		-- Tuples all have generics..
					-- hmm: that's a *lot* of code
291

292
unitTyCon     = tupleTyCon Boxed 0
293 294
unitDataCon   = head (tyConDataCons unitTyCon)
unitDataConId = dataConWorkId unitDataCon
295

296
pairTyCon = tupleTyCon Boxed 2
297

298 299
unboxedSingletonTyCon   = tupleTyCon Unboxed 1
unboxedSingletonDataCon = tupleCon   Unboxed 1
300

301 302
unboxedPairTyCon   = tupleTyCon Unboxed 2
unboxedPairDataCon = tupleCon   Unboxed 2
303
\end{code}
304

305 306 307 308 309 310 311
%************************************************************************
%*									*
\subsection[TysWiredIn-boxed-prim]{The ``boxed primitive'' types (@Char@, @Int@, etc)}
%*									*
%************************************************************************

\begin{code}
312
charTy = mkTyConTy charTyCon
313

314
charTyCon   = pcNonRecDataTyCon charTyConName [] [charDataCon]
315
charDataCon = pcDataCon charDataConName [] [charPrimTy] charTyCon
316 317

stringTy = mkListTy charTy -- convenience only
318 319 320
\end{code}

\begin{code}
321
intTy = mkTyConTy intTyCon 
322

323
intTyCon = pcNonRecDataTyCon intTyConName [] [intDataCon]
324
intDataCon = pcDataCon intDataConName [] [intPrimTy] intTyCon
325 326 327
\end{code}

\begin{code}
328
floatTy	= mkTyConTy floatTyCon
329

330
floatTyCon   = pcNonRecDataTyCon floatTyConName   [] [floatDataCon]
331
floatDataCon = pcDataCon         floatDataConName [] [floatPrimTy] floatTyCon
332 333 334
\end{code}

\begin{code}
335
doubleTy = mkTyConTy doubleTyCon
336

337
doubleTyCon   = pcNonRecDataTyCon doubleTyConName   [] [doubleDataCon]
338
doubleDataCon = pcDataCon	  doubleDataConName [] [doublePrimTy] doubleTyCon
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
\end{code}


%************************************************************************
%*									*
\subsection[TysWiredIn-Bool]{The @Bool@ type}
%*									*
%************************************************************************

An ordinary enumeration type, but deeply wired in.  There are no
magical operations on @Bool@ (just the regular Prelude code).

{\em BEGIN IDLE SPECULATION BY SIMON}

This is not the only way to encode @Bool@.  A more obvious coding makes
@Bool@ just a boxed up version of @Bool#@, like this:
\begin{verbatim}
type Bool# = Int#
data Bool = MkBool Bool#
\end{verbatim}

Unfortunately, this doesn't correspond to what the Report says @Bool@
looks like!  Furthermore, we get slightly less efficient code (I
think) with this coding. @gtInt@ would look like this:

\begin{verbatim}
gtInt :: Int -> Int -> Bool
gtInt x y = case x of I# x# ->
	    case y of I# y# ->
	    case (gtIntPrim x# y#) of
		b# -> MkBool b#
\end{verbatim}

Notice that the result of the @gtIntPrim@ comparison has to be turned
into an integer (here called @b#@), and returned in a @MkBool@ box.

The @if@ expression would compile to this:
\begin{verbatim}
case (gtInt x y) of
  MkBool b# -> case b# of { 1# -> e1; 0# -> e2 }
\end{verbatim}

I think this code is a little less efficient than the previous code,
but I'm not certain.  At all events, corresponding with the Report is
important.  The interesting thing is that the language is expressive
enough to describe more than one alternative; and that a type doesn't
necessarily need to be a straightforwardly boxed version of its
primitive counterpart.

{\em END IDLE SPECULATION BY SIMON}

\begin{code}
391
boolTy = mkTyConTy boolTyCon
392

393
boolTyCon = pcTyCon True NonRecursive boolTyConName
394
		    [] [falseDataCon, trueDataCon]
395

396 397
falseDataCon = pcDataCon falseDataConName [] [] boolTyCon
trueDataCon  = pcDataCon trueDataConName  [] [] boolTyCon
398

399 400
falseDataConId = dataConWorkId falseDataCon
trueDataConId  = dataConWorkId trueDataCon
401 402 403 404 405 406 407 408 409
\end{code}

%************************************************************************
%*									*
\subsection[TysWiredIn-List]{The @List@ type (incl ``build'' magic)}
%*									*
%************************************************************************

Special syntax, deeply wired in, but otherwise an ordinary algebraic
410
data types:
411
\begin{verbatim}
412 413 414 415
data [] a = [] | a : (List a)
data () = ()
data (,) a b = (,,) a b
...
416 417 418
\end{verbatim}

\begin{code}
419
mkListTy :: Type -> Type
420
mkListTy ty = mkTyConApp listTyCon [ty]
421

422
listTyCon = pcRecDataTyCon listTyConName alpha_tyvar [nilDataCon, consDataCon]
423

424 425 426 427
nilDataCon  = pcDataCon nilDataConName alpha_tyvar [] listTyCon
consDataCon = pcDataConWithFixity True {- Declared infix -}
	       consDataConName
 	       alpha_tyvar [alphaTy, mkTyConApp listTyCon alpha_ty] listTyCon
428 429 430
-- Interesting: polymorphic recursion would help here.
-- We can't use (mkListTy alphaTy) in the defn of consDataCon, else mkListTy
-- gets the over-specific type (Type -> Type)
431 432 433 434 435 436 437 438 439 440 441 442 443
\end{code}

%************************************************************************
%*									*
\subsection[TysWiredIn-Tuples]{The @Tuple@ types}
%*									*
%************************************************************************

The tuple types are definitely magic, because they form an infinite
family.

\begin{itemize}
\item
444
They have a special family of type constructors, of type @TyCon@
445 446 447 448
These contain the tycon arity, but don't require a Unique.

\item
They have a special family of constructors, of type
449
@Id@. Again these contain their arity but don't need a Unique.
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479

\item
There should be a magic way of generating the info tables and
entry code for all tuples.

But at the moment we just compile a Haskell source
file\srcloc{lib/prelude/...} containing declarations like:
\begin{verbatim}
data Tuple0		= Tup0
data Tuple2  a b	= Tup2	a b
data Tuple3  a b c	= Tup3	a b c
data Tuple4  a b c d	= Tup4	a b c d
...
\end{verbatim}
The print-names associated with the magic @Id@s for tuple constructors
``just happen'' to be the same as those generated by these
declarations.

\item
The instance environment should have a magic way to know
that each tuple type is an instances of classes @Eq@, @Ix@, @Ord@ and
so on. \ToDo{Not implemented yet.}

\item
There should also be a way to generate the appropriate code for each
of these instances, but (like the info tables and entry code) it is
done by enumeration\srcloc{lib/prelude/InTup?.hs}.
\end{itemize}

\begin{code}
480 481
mkTupleTy :: Boxity -> Int -> [Type] -> Type
mkTupleTy boxity arity tys = mkTyConApp (tupleTyCon boxity arity) tys
482

simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
483
unitTy = mkTupleTy Boxed 0 []
484
\end{code}
485

chak's avatar
chak committed
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502
%************************************************************************
%*									*
\subsection[TysWiredIn-PArr]{The @[::]@ type}
%*									*
%************************************************************************

Special syntax for parallel arrays needs some wired in definitions.

\begin{code}
-- construct a type representing the application of the parallel array
-- constructor 
--
mkPArrTy    :: Type -> Type
mkPArrTy ty  = mkTyConApp parrTyCon [ty]

-- represents the type constructor of parallel arrays
--
503
--  * this must match the definition in `PrelPArr'
chak's avatar
chak committed
504 505 506 507 508 509
--
-- NB: Although the constructor is given here, it will not be accessible in
--     user code as it is not in the environment of any compiled module except
--     `PrelPArr'.
--
parrTyCon :: TyCon
510
parrTyCon  = pcNonRecDataTyCon parrTyConName alpha_tyvar [parrDataCon]
chak's avatar
chak committed
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528

parrDataCon :: DataCon
parrDataCon  = pcDataCon 
	         parrDataConName 
		 alpha_tyvar		-- forall'ed type variables
		 [intPrimTy,		-- 1st argument: Int#
		  mkTyConApp		-- 2nd argument: Array# a
		    arrayPrimTyCon 
		    alpha_ty] 
		 parrTyCon

-- check whether a type constructor is the constructor for parallel arrays
--
isPArrTyCon    :: TyCon -> Bool
isPArrTyCon tc  = tyConName tc == parrTyConName

-- fake array constructors
--
529
--  * these constructors are never really used to represent array values;
chak's avatar
chak committed
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546
--   however, they are very convenient during desugaring (and, in particular,
--   in the pattern matching compiler) to treat array pattern just like
--   yet another constructor pattern
--
parrFakeCon                        :: Arity -> DataCon
parrFakeCon i | i > mAX_TUPLE_SIZE  = mkPArrFakeCon  i	-- build one specially
parrFakeCon i                       = parrFakeConArr!i

-- pre-defined set of constructors
--
parrFakeConArr :: Array Int DataCon
parrFakeConArr  = array (0, mAX_TUPLE_SIZE) [(i, mkPArrFakeCon i)   
					    | i <- [0..mAX_TUPLE_SIZE]]

-- build a fake parallel array constructor for the given arity
--
mkPArrFakeCon       :: Int -> DataCon
547
mkPArrFakeCon arity  = data_con
chak's avatar
chak committed
548
  where
549
	data_con  = pcDataCon name [tyvar] tyvarTys parrTyCon
chak's avatar
chak committed
550 551
	tyvar     = head alphaTyVars
	tyvarTys  = replicate arity $ mkTyVarTy tyvar
552
        nameStr   = mkFastString ("MkPArr" ++ show arity)
Simon Marlow's avatar
Simon Marlow committed
553
	name      = mkWiredInName gHC_PARR (mkOccNameFS dataName nameStr) uniq
554
				  (ADataCon data_con) UserSyntax
chak's avatar
chak committed
555 556 557 558 559 560 561 562
	uniq      = mkPArrDataConUnique arity

-- checks whether a data constructor is a fake constructor for parallel arrays
--
isPArrFakeCon      :: DataCon -> Bool
isPArrFakeCon dcon  = dcon == parrFakeCon (dataConSourceArity dcon)
\end{code}

563