PrelNames.lhs 62.9 KB
Newer Older
1 2 3
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
4 5 6
\section[PrelNames]{Definitions of prelude modules and names}


7
Nota Bene: all Names defined in here should come from the base package
8

Thomas Schilling's avatar
Thomas Schilling committed
9
 - ModuleNames for prelude modules, 
10 11
	e.g.	pREL_BASE_Name :: ModuleName

Thomas Schilling's avatar
Thomas Schilling committed
12
 - Modules for prelude modules
13 14
	e.g.	pREL_Base :: Module

Thomas Schilling's avatar
Thomas Schilling committed
15 16
 - Uniques for Ids, DataCons, TyCons and Classes that the compiler 
   "knows about" in some way
17 18 19
	e.g.	intTyConKey :: Unique
		minusClassOpKey :: Unique

Thomas Schilling's avatar
Thomas Schilling committed
20 21
 - Names for Ids, DataCons, TyCons and Classes that the compiler 
   "knows about" in some way
22 23
	e.g.	intTyConName :: Name
		minusName    :: Name
Thomas Schilling's avatar
Thomas Schilling committed
24
   One of these Names contains
25 26
	(a) the module and occurrence name of the thing
	(b) its Unique
Thomas Schilling's avatar
Thomas Schilling committed
27 28 29 30 31
   The may way the compiler "knows about" one of these things is
   where the type checker or desugarer needs to look it up. For
   example, when desugaring list comprehensions the desugarer
   needs to conjure up 'foldr'.  It does this by looking up
   foldrName in the environment.
32

Thomas Schilling's avatar
Thomas Schilling committed
33 34 35
 - RdrNames for Ids, DataCons etc that the compiler may emit into
   generated code (e.g. for deriving).  It's not necessary to know
   the uniques for these guys, only their names
36

37 38

\begin{code}
39 40
module PrelNames (
	Unique, Uniquable(..), hasKey, 	-- Re-exported for convenience
41

42
	-----------------------------------------------------------
43 44
	module PrelNames,	-- A huge bunch of (a) Names,  e.g. intTyConName
				--		   (b) Uniques e.g. intTyConKey
45 46
				--		   (c) Groups of classes and types
				--		   (d) miscellaneous things
47
				-- So many that we export them all
48
    ) where
49 50 51

#include "HsVersions.h"

52
import Module
Ian Lynagh's avatar
Ian Lynagh committed
53
import OccName
54
import RdrName	  ( RdrName, nameRdrName, mkOrig, rdrNameOcc, mkUnqual )
55 56
import Unique	  ( Unique, Uniquable(..), hasKey,
		    mkPreludeMiscIdUnique, mkPreludeDataConUnique,
57
		    mkPreludeTyConUnique, mkPreludeClassUnique,
58
		    mkTupleTyConUnique
59
		  ) 
60
import BasicTypes ( Boxity(..), Arity )
61
import Name       ( Name, mkInternalName, mkExternalName, mkSystemVarName )
62
import SrcLoc
63
import FastString
64 65
\end{code}

66

67 68 69 70 71 72 73 74 75
%************************************************************************
%*									*
\subsection{Local Names}
%*									*
%************************************************************************

This *local* name is used by the interactive stuff

\begin{code}
Ian Lynagh's avatar
Ian Lynagh committed
76
itName :: Unique -> Name
Ian Lynagh's avatar
Ian Lynagh committed
77
itName uniq = mkInternalName uniq (mkOccNameFS varName (fsLit "it")) noSrcSpan
78 79 80 81 82 83
\end{code}

\begin{code}
-- mkUnboundName makes a place-holder Name; it shouldn't be looked at except possibly
-- during compiler debugging.
mkUnboundName :: RdrName -> Name
84
mkUnboundName rdr_name = mkInternalName unboundKey (rdrNameOcc rdr_name) noSrcSpan
85 86 87 88 89 90

isUnboundName :: Name -> Bool
isUnboundName name = name `hasKey` unboundKey
\end{code}


91
%************************************************************************
92
%*                                                                      *
93
\subsection{Known key Names}
94
%*                                                                      *
95 96
%************************************************************************

97
This section tells what the compiler knows about the association of
98 99
names with uniques.  These ones are the *non* wired-in ones.  The
wired in ones are defined in TysWiredIn etc.
100

101 102 103 104 105 106
The names for DPH can come from one of multiple backend packages. At the point where 
'basicKnownKeyNames' is used, we don't know which backend it will be.  Hence, we list
the names for multiple backends.  That works out fine, although they use the same uniques,
as we are guaranteed to only load one backend; hence, only one of the different names
sharing a unique will be used.

107
\begin{code}
108 109
basicKnownKeyNames :: [Name]
basicKnownKeyNames
110
 = genericTyConNames
111
 ++ typeableClassNames
112
 ++ dphKnownKeyNames dphSeqPackageId ++ dphKnownKeyNames dphParPackageId
113
 ++ [	-- Type constructors (synonyms especially)
114
	ioTyConName, ioDataConName,
115
	runMainIOName,
116 117
	orderingTyConName,
	rationalTyConName,
118
	stringTyConName,
119 120
	ratioDataConName,
	ratioTyConName,
121
	integerTyConName, smallIntegerName,
122 123 124 125

	--  Classes.  *Must* include:
	--  	classes that are grabbed by key (e.g., eqClassKey)
	--  	classes in "Class.standardClassKeys" (quite a few)
126 127 128 129 130 131 132 133 134 135 136 137 138
	eqClassName,			-- mentioned, derivable
	ordClassName,			-- derivable
	boundedClassName,		-- derivable
	numClassName,			-- mentioned, numeric
	enumClassName,			-- derivable
	monadClassName,
    	functorClassName,
	realClassName,			-- numeric
	integralClassName,		-- numeric
	fractionalClassName,		-- numeric
	floatingClassName,		-- numeric
	realFracClassName,		-- numeric
	realFloatClassName,		-- numeric
139
	dataClassName, 
140
	isStringClassName,
141 142 143
	applicativeClassName,
	foldableClassName,
	traversableClassName,
144

145
	-- Numeric stuff
146 147 148 149 150 151
        negateName, minusName, geName, eqName,

        -- Conversion functions
        fromRationalName, fromIntegerName,
        toIntegerName, toRationalName,
        fromIntegralName, realToFracName,
152 153 154

        -- String stuff
        fromStringName,
155 156 157 158 159 160 161
	
	-- Enum stuff
	enumFromName, enumFromThenName,	
	enumFromThenToName, enumFromToName,

	-- Monad stuff
	thenIOName, bindIOName, returnIOName, failIOName,
162
	failMName, bindMName, thenMName, returnMName,
163

164 165 166
	-- MonadRec stuff
	mfixName,

167 168 169 170
	-- Arrow stuff
	arrAName, composeAName, firstAName,
	appAName, choiceAName, loopAName,

171 172 173 174 175 176 177 178
	-- Ix stuff
	ixClassName, 

	-- Show stuff
	showClassName, 

	-- Read stuff
	readClassName, 
179

180
	-- Stable pointers
181
	newStablePtrName,
182

183
    -- GHC Extensions
184
        groupWithName,
185

186
	-- Strings and lists
187 188
	unpackCStringName, unpackCStringAppendName,
	unpackCStringFoldrName, unpackCStringUtf8Name,
189 190

	-- List operations
191
	concatName, filterName, mapName,
192
	zipName, foldrName, buildName, augmentName, appendName,
193

194 195
        dollarName,	    -- The ($) apply function

196
	-- FFI primitive types that are not wired-in.
197
	stablePtrTyConName, ptrTyConName, funPtrTyConName,
198
	int8TyConName, int16TyConName, int32TyConName, int64TyConName,
199
	wordTyConName, word8TyConName, word16TyConName, word32TyConName, word64TyConName,
200 201

	-- Others
202
	otherwiseIdName, inlineIdName,
203
	plusIntegerName, timesIntegerName,
David Himmelstrup's avatar
David Himmelstrup committed
204
	eqStringName, assertName, breakpointName, breakpointCondName,
205
        breakpointAutoName,  opaqueTyConName,
David Himmelstrup's avatar
David Himmelstrup committed
206
        assertErrorName, runSTRepName,
207 208 209 210 211
	printName, fstName, sndName,

	-- MonadFix
	monadFixClassName, mfixName,

212 213 214
	-- Other classes
	randomClassName, randomGenClassName, monadPlusClassName,

215
        -- Annotation type checking
216
        toAnnotationWrapperName
217

218 219 220
	-- The Either type
	, eitherTyConName, leftDataConName, rightDataConName

sof's avatar
sof committed
221 222 223
	-- dotnet interop
	, objectTyConName, marshalObjectName, unmarshalObjectName
	, marshalStringName, unmarshalStringName, checkDotnetResName
224 225 226 227 228
	
	-- Generics
	, rep0ClassName, rep1ClassName
	, datatypeClassName, constructorClassName, selectorClassName
	
229
    ]
230

231
genericTyConNames :: [Name]
232 233 234 235 236 237 238 239 240 241 242
genericTyConNames = [
    -- Old stuff
    crossTyConName, plusTyConName, genUnitTyConName,
    -- New stuff
    v1TyConName, u1TyConName, par1TyConName, rec1TyConName,
    k1TyConName, m1TyConName, sumTyConName, prodTyConName,
    compTyConName, rTyConName, pTyConName, dTyConName,
    cTyConName, sTyConName, rec0TyConName, par0TyConName,
    d1TyConName, c1TyConName, s1TyConName, noSelTyConName,
    rep0TyConName, rep1TyConName
  ]
243 244 245 246 247 248 249 250 251 252 253 254 255 256

-- Know names from the DPH package which vary depending on the selected DPH backend.
--
dphKnownKeyNames :: PackageId -> [Name]
dphKnownKeyNames dphPkg
  = map ($ dphPkg)
    [
        -- Parallel array operations
	  nullPName, lengthPName, replicatePName,	singletonPName, mapPName,
	  filterPName, zipPName, crossMapPName, indexPName,
	  toPName, emptyPName, appPName,
  	enumFromToPName, enumFromThenToPName

    ]
257 258 259
\end{code}


260 261 262 263 264 265
%************************************************************************
%*									*
\subsection{Module names}
%*									*
%************************************************************************

266 267

--MetaHaskell Extension Add a new module here
268
\begin{code}
Ian Lynagh's avatar
Ian Lynagh committed
269
pRELUDE :: Module
Simon Marlow's avatar
Simon Marlow committed
270
pRELUDE		= mkBaseModule_ pRELUDE_NAME
Ian Lynagh's avatar
Ian Lynagh committed
271

Ian Lynagh's avatar
Ian Lynagh committed
272
gHC_PRIM, gHC_TYPES, gHC_UNIT, gHC_ORDERING, gHC_GENERICS,
Ian Lynagh's avatar
Ian Lynagh committed
273 274
    gHC_MAGIC,
    gHC_CLASSES, gHC_BASE, gHC_ENUM,
275
    gHC_SHOW, gHC_READ, gHC_NUM, gHC_INTEGER, gHC_INTEGER_TYPE, gHC_LIST,
276
    gHC_TUPLE, dATA_TUPLE, dATA_EITHER, dATA_STRING, dATA_FOLDABLE, dATA_TRAVERSABLE,
277
    gHC_PACK, gHC_CONC, gHC_IO, gHC_IO_Exception,
Ian Lynagh's avatar
Ian Lynagh committed
278 279
    gHC_ST, gHC_ARR, gHC_STABLE, gHC_ADDR, gHC_PTR, gHC_ERR, gHC_REAL,
    gHC_FLOAT, gHC_TOP_HANDLER, sYSTEM_IO, dYNAMIC, tYPEABLE, gENERICS,
280
    dOTNET, rEAD_PREC, lEX, gHC_INT, gHC_WORD, mONAD, mONAD_FIX, aRROW, cONTROL_APPLICATIVE,
281
    gHC_DESUGAR, rANDOM, gHC_EXTS, cONTROL_EXCEPTION_BASE :: Module
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
282

Ian Lynagh's avatar
Ian Lynagh committed
283
gHC_PRIM	= mkPrimModule (fsLit "GHC.Prim")   -- Primitive types and values
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
284
gHC_TYPES       = mkPrimModule (fsLit "GHC.Types")
Ian Lynagh's avatar
Ian Lynagh committed
285
gHC_UNIT	= mkPrimModule (fsLit "GHC.Unit")
Ian Lynagh's avatar
Ian Lynagh committed
286 287
gHC_ORDERING	= mkPrimModule (fsLit "GHC.Ordering")
gHC_GENERICS	= mkPrimModule (fsLit "GHC.Generics")
Ian Lynagh's avatar
Ian Lynagh committed
288
gHC_MAGIC	= mkPrimModule (fsLit "GHC.Magic")
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
289

290
gHC_CLASSES	= mkBaseModule (fsLit "GHC.Classes")
Ian Lynagh's avatar
Ian Lynagh committed
291 292 293 294 295 296
gHC_BASE	= mkBaseModule (fsLit "GHC.Base")
gHC_ENUM	= mkBaseModule (fsLit "GHC.Enum")
gHC_SHOW	= mkBaseModule (fsLit "GHC.Show")
gHC_READ	= mkBaseModule (fsLit "GHC.Read")
gHC_NUM		= mkBaseModule (fsLit "GHC.Num")
gHC_INTEGER	= mkIntegerModule (fsLit "GHC.Integer")
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
297
gHC_INTEGER_TYPE= mkIntegerModule (fsLit "GHC.Integer.Type")
298 299 300
gHC_LIST        = mkBaseModule (fsLit "GHC.List")
gHC_TUPLE       = mkPrimModule (fsLit "GHC.Tuple")
dATA_TUPLE      = mkBaseModule (fsLit "Data.Tuple")
Ian Lynagh's avatar
Ian Lynagh committed
301 302
dATA_EITHER	= mkBaseModule (fsLit "Data.Either")
dATA_STRING	= mkBaseModule (fsLit "Data.String")
303 304
dATA_FOLDABLE	= mkBaseModule (fsLit "Data.Foldable")
dATA_TRAVERSABLE= mkBaseModule (fsLit "Data.Traversable")
Ian Lynagh's avatar
Ian Lynagh committed
305 306
gHC_PACK	= mkBaseModule (fsLit "GHC.Pack")
gHC_CONC	= mkBaseModule (fsLit "GHC.Conc")
307 308
gHC_IO    	= mkBaseModule (fsLit "GHC.IO")
gHC_IO_Exception = mkBaseModule (fsLit "GHC.IO.Exception")
Ian Lynagh's avatar
Ian Lynagh committed
309 310 311 312 313 314 315 316 317 318 319 320
gHC_ST		= mkBaseModule (fsLit "GHC.ST")
gHC_ARR		= mkBaseModule (fsLit "GHC.Arr")
gHC_STABLE	= mkBaseModule (fsLit "GHC.Stable")
gHC_ADDR	= mkBaseModule (fsLit "GHC.Addr")
gHC_PTR		= mkBaseModule (fsLit "GHC.Ptr")
gHC_ERR		= mkBaseModule (fsLit "GHC.Err")
gHC_REAL	= mkBaseModule (fsLit "GHC.Real")
gHC_FLOAT	= mkBaseModule (fsLit "GHC.Float")
gHC_TOP_HANDLER	= mkBaseModule (fsLit "GHC.TopHandler")
sYSTEM_IO	= mkBaseModule (fsLit "System.IO")
dYNAMIC		= mkBaseModule (fsLit "Data.Dynamic")
tYPEABLE	= mkBaseModule (fsLit "Data.Typeable")
321
gENERICS        = mkBaseModule (fsLit "Data.Data")
Ian Lynagh's avatar
Ian Lynagh committed
322 323
dOTNET		= mkBaseModule (fsLit "GHC.Dotnet")
rEAD_PREC	= mkBaseModule (fsLit "Text.ParserCombinators.ReadPrec")
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
324
lEX		= mkBaseModule (fsLit "Text.Read.Lex")
Ian Lynagh's avatar
Ian Lynagh committed
325 326 327 328 329
gHC_INT		= mkBaseModule (fsLit "GHC.Int")
gHC_WORD	= mkBaseModule (fsLit "GHC.Word")
mONAD		= mkBaseModule (fsLit "Control.Monad")
mONAD_FIX	= mkBaseModule (fsLit "Control.Monad.Fix")
aRROW		= mkBaseModule (fsLit "Control.Arrow")
330
cONTROL_APPLICATIVE = mkBaseModule (fsLit "Control.Applicative")
Ian Lynagh's avatar
Ian Lynagh committed
331 332 333
gHC_DESUGAR = mkBaseModule (fsLit "GHC.Desugar")
rANDOM		= mkBaseModule (fsLit "System.Random")
gHC_EXTS	= mkBaseModule (fsLit "GHC.Exts")
334
cONTROL_EXCEPTION_BASE = mkBaseModule (fsLit "Control.Exception.Base")
Simon Marlow's avatar
Simon Marlow committed
335

336 337 338 339 340 341
gHC_PARR :: PackageId -> Module
gHC_PARR pkg = mkModule pkg (mkModuleNameFS (fsLit "Data.Array.Parallel"))

gHC_PARR' :: Module
gHC_PARR' = mkBaseModule (fsLit "GHC.PArr")

Ian Lynagh's avatar
Ian Lynagh committed
342
mAIN, rOOT_MAIN :: Module
Simon Marlow's avatar
Simon Marlow committed
343
mAIN	        = mkMainModule_ mAIN_NAME
Ian Lynagh's avatar
Ian Lynagh committed
344
rOOT_MAIN	= mkMainModule (fsLit ":Main") -- Root module for initialisation 
Simon Marlow's avatar
Simon Marlow committed
345

346
	-- The ':xxx' makes a module name that the user can never
347 348 349
	-- use himself.  The z-encoding for ':' is "ZC", so the z-encoded
	-- module name still starts with a capital letter, which keeps
	-- the z-encoded version consistent.
350
iNTERACTIVE :: Module
Ian Lynagh's avatar
Ian Lynagh committed
351
iNTERACTIVE    = mkMainModule (fsLit ":Interactive")
Simon Marlow's avatar
Simon Marlow committed
352

Ian Lynagh's avatar
Ian Lynagh committed
353
pRELUDE_NAME, mAIN_NAME :: ModuleName
Ian Lynagh's avatar
Ian Lynagh committed
354 355
pRELUDE_NAME   = mkModuleNameFS (fsLit "Prelude")
mAIN_NAME      = mkModuleNameFS (fsLit "Main")
Simon Marlow's avatar
Simon Marlow committed
356

Ian Lynagh's avatar
Ian Lynagh committed
357 358 359 360 361 362
mkPrimModule :: FastString -> Module
mkPrimModule m = mkModule primPackageId (mkModuleNameFS m)

mkIntegerModule :: FastString -> Module
mkIntegerModule m = mkModule integerPackageId (mkModuleNameFS m)

Simon Marlow's avatar
Simon Marlow committed
363 364 365 366 367 368 369 370
mkBaseModule :: FastString -> Module
mkBaseModule m = mkModule basePackageId (mkModuleNameFS m)

mkBaseModule_ :: ModuleName -> Module
mkBaseModule_ m = mkModule basePackageId m

mkMainModule :: FastString -> Module
mkMainModule m = mkModule mainPackageId (mkModuleNameFS m)
371

Simon Marlow's avatar
Simon Marlow committed
372 373
mkMainModule_ :: ModuleName -> Module
mkMainModule_ m = mkModule mainPackageId m
374 375 376 377 378 379 380 381 382
\end{code}

%************************************************************************
%*									*
\subsection{Constructing the names of tuples
%*									*
%************************************************************************

\begin{code}
383
mkTupleModule :: Boxity -> Arity -> Module
Ian Lynagh's avatar
Ian Lynagh committed
384
mkTupleModule Boxed   0 = gHC_UNIT
385
mkTupleModule Boxed   _ = gHC_TUPLE
386
mkTupleModule Unboxed _ = gHC_PRIM
387 388 389
\end{code}


390 391
%************************************************************************
%*									*
392
			RdrNames
393 394 395 396
%*									*
%************************************************************************

\begin{code}
Ian Lynagh's avatar
Ian Lynagh committed
397
main_RDR_Unqual    :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
398
main_RDR_Unqual	= mkUnqual varName (fsLit "main")
399 400 401
	-- We definitely don't want an Orig RdrName, because
	-- main might, in principle, be imported into module Main

402
forall_tv_RDR, dot_tv_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
403 404
forall_tv_RDR = mkUnqual tvName (fsLit "forall")
dot_tv_RDR    = mkUnqual tvName (fsLit ".")
405

Ian Lynagh's avatar
Ian Lynagh committed
406 407
eq_RDR, ge_RDR, ne_RDR, le_RDR, lt_RDR, gt_RDR, compare_RDR,
    ltTag_RDR, eqTag_RDR, gtTag_RDR :: RdrName
408 409
eq_RDR 			= nameRdrName eqName
ge_RDR 			= nameRdrName geName
410 411 412 413 414
ne_RDR 			= varQual_RDR  gHC_CLASSES (fsLit "/=")
le_RDR 			= varQual_RDR  gHC_CLASSES (fsLit "<=") 
lt_RDR 			= varQual_RDR  gHC_CLASSES (fsLit "<") 
gt_RDR 			= varQual_RDR  gHC_CLASSES (fsLit ">")  
compare_RDR		= varQual_RDR  gHC_CLASSES (fsLit "compare") 
Ian Lynagh's avatar
Ian Lynagh committed
415 416 417
ltTag_RDR		= dataQual_RDR gHC_ORDERING (fsLit "LT") 
eqTag_RDR		= dataQual_RDR gHC_ORDERING (fsLit "EQ")
gtTag_RDR		= dataQual_RDR gHC_ORDERING (fsLit "GT")
418

Ian Lynagh's avatar
Ian Lynagh committed
419 420
eqClass_RDR, numClass_RDR, ordClass_RDR, enumClass_RDR, monadClass_RDR
    :: RdrName
421 422 423 424 425 426
eqClass_RDR		= nameRdrName eqClassName
numClass_RDR 		= nameRdrName numClassName
ordClass_RDR 		= nameRdrName ordClassName
enumClass_RDR		= nameRdrName enumClassName
monadClass_RDR		= nameRdrName monadClassName

Ian Lynagh's avatar
Ian Lynagh committed
427
map_RDR, append_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
428 429
map_RDR 		= varQual_RDR gHC_BASE (fsLit "map")
append_RDR 		= varQual_RDR gHC_BASE (fsLit "++")
430

Ian Lynagh's avatar
Ian Lynagh committed
431
foldr_RDR, build_RDR, returnM_RDR, bindM_RDR, failM_RDR :: RdrName
432 433 434 435 436 437
foldr_RDR 		= nameRdrName foldrName
build_RDR 		= nameRdrName buildName
returnM_RDR 		= nameRdrName returnMName
bindM_RDR 		= nameRdrName bindMName
failM_RDR 		= nameRdrName failMName

Ian Lynagh's avatar
Ian Lynagh committed
438
left_RDR, right_RDR :: RdrName
439 440 441
left_RDR		= nameRdrName leftDataConName
right_RDR		= nameRdrName rightDataConName

Ian Lynagh's avatar
Ian Lynagh committed
442
fromEnum_RDR, toEnum_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
443 444
fromEnum_RDR		= varQual_RDR gHC_ENUM (fsLit "fromEnum")
toEnum_RDR		= varQual_RDR gHC_ENUM (fsLit "toEnum")
445

Ian Lynagh's avatar
Ian Lynagh committed
446
enumFrom_RDR, enumFromTo_RDR, enumFromThen_RDR, enumFromThenTo_RDR :: RdrName
447 448 449 450 451
enumFrom_RDR		= nameRdrName enumFromName
enumFromTo_RDR 		= nameRdrName enumFromToName
enumFromThen_RDR	= nameRdrName enumFromThenName
enumFromThenTo_RDR	= nameRdrName enumFromThenToName

Ian Lynagh's avatar
Ian Lynagh committed
452
ratioDataCon_RDR, plusInteger_RDR, timesInteger_RDR :: RdrName
453 454 455 456
ratioDataCon_RDR	= nameRdrName ratioDataConName
plusInteger_RDR		= nameRdrName plusIntegerName
timesInteger_RDR	= nameRdrName timesIntegerName

Ian Lynagh's avatar
Ian Lynagh committed
457
ioDataCon_RDR :: RdrName
458 459
ioDataCon_RDR		= nameRdrName ioDataConName

Ian Lynagh's avatar
Ian Lynagh committed
460 461
eqString_RDR, unpackCString_RDR, unpackCStringFoldr_RDR,
    unpackCStringUtf8_RDR :: RdrName
462 463 464 465 466
eqString_RDR		= nameRdrName eqStringName
unpackCString_RDR      	= nameRdrName unpackCStringName
unpackCStringFoldr_RDR 	= nameRdrName unpackCStringFoldrName
unpackCStringUtf8_RDR  	= nameRdrName unpackCStringUtf8Name

Ian Lynagh's avatar
Ian Lynagh committed
467
newStablePtr_RDR, wordDataCon_RDR :: RdrName
468
newStablePtr_RDR 	= nameRdrName newStablePtrName
Ian Lynagh's avatar
Ian Lynagh committed
469
wordDataCon_RDR		= dataQual_RDR gHC_WORD (fsLit "W#")
470

Ian Lynagh's avatar
Ian Lynagh committed
471
bindIO_RDR, returnIO_RDR :: RdrName
472 473 474
bindIO_RDR	  	= nameRdrName bindIOName
returnIO_RDR	  	= nameRdrName returnIOName

Ian Lynagh's avatar
Ian Lynagh committed
475
fromInteger_RDR, fromRational_RDR, minus_RDR, times_RDR, plus_RDR :: RdrName
476 477 478
fromInteger_RDR		= nameRdrName fromIntegerName
fromRational_RDR	= nameRdrName fromRationalName
minus_RDR		= nameRdrName minusName
Ian Lynagh's avatar
Ian Lynagh committed
479 480
times_RDR		= varQual_RDR  gHC_NUM (fsLit "*")
plus_RDR                = varQual_RDR gHC_NUM (fsLit "+")
Simon Marlow's avatar
Simon Marlow committed
481

Ian Lynagh's avatar
Ian Lynagh committed
482
fromString_RDR :: RdrName
483 484
fromString_RDR		= nameRdrName fromStringName

Ian Lynagh's avatar
Ian Lynagh committed
485
compose_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
486
compose_RDR		= varQual_RDR gHC_BASE (fsLit ".")
Simon Marlow's avatar
Simon Marlow committed
487

Ian Lynagh's avatar
Ian Lynagh committed
488
not_RDR, getTag_RDR, succ_RDR, pred_RDR, minBound_RDR, maxBound_RDR,
489
    and_RDR, range_RDR, inRange_RDR, index_RDR,
Ian Lynagh's avatar
Ian Lynagh committed
490
    unsafeIndex_RDR, unsafeRangeSize_RDR :: RdrName
491
and_RDR			= varQual_RDR gHC_CLASSES (fsLit "&&")
492
not_RDR 		= varQual_RDR gHC_CLASSES (fsLit "not")
Ian Lynagh's avatar
Ian Lynagh committed
493 494 495 496 497 498 499 500 501 502
getTag_RDR	 	= varQual_RDR gHC_BASE (fsLit "getTag")
succ_RDR 		= varQual_RDR gHC_ENUM (fsLit "succ")
pred_RDR                = varQual_RDR gHC_ENUM (fsLit "pred")
minBound_RDR            = varQual_RDR gHC_ENUM (fsLit "minBound")
maxBound_RDR            = varQual_RDR gHC_ENUM (fsLit "maxBound")
range_RDR               = varQual_RDR gHC_ARR (fsLit "range")
inRange_RDR             = varQual_RDR gHC_ARR (fsLit "inRange")
index_RDR		= varQual_RDR gHC_ARR (fsLit "index")
unsafeIndex_RDR		= varQual_RDR gHC_ARR (fsLit "unsafeIndex")
unsafeRangeSize_RDR	= varQual_RDR gHC_ARR (fsLit "unsafeRangeSize")
Simon Marlow's avatar
Simon Marlow committed
503

Ian Lynagh's avatar
Ian Lynagh committed
504 505
readList_RDR, readListDefault_RDR, readListPrec_RDR, readListPrecDefault_RDR,
    readPrec_RDR, parens_RDR, choose_RDR, lexP_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
506 507 508 509 510 511 512 513
readList_RDR            = varQual_RDR gHC_READ (fsLit "readList")
readListDefault_RDR     = varQual_RDR gHC_READ (fsLit "readListDefault")
readListPrec_RDR        = varQual_RDR gHC_READ (fsLit "readListPrec")
readListPrecDefault_RDR = varQual_RDR gHC_READ (fsLit "readListPrecDefault")
readPrec_RDR            = varQual_RDR gHC_READ (fsLit "readPrec")
parens_RDR              = varQual_RDR gHC_READ (fsLit "parens")
choose_RDR              = varQual_RDR gHC_READ (fsLit "choose")
lexP_RDR                = varQual_RDR gHC_READ (fsLit "lexP")
514

Ian Lynagh's avatar
Ian Lynagh committed
515
punc_RDR, ident_RDR, symbol_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
516 517 518
punc_RDR                = dataQual_RDR lEX (fsLit "Punc")
ident_RDR               = dataQual_RDR lEX (fsLit "Ident")
symbol_RDR              = dataQual_RDR lEX (fsLit "Symbol")
519

Ian Lynagh's avatar
Ian Lynagh committed
520
step_RDR, alt_RDR, reset_RDR, prec_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
521 522 523 524
step_RDR                = varQual_RDR  rEAD_PREC (fsLit "step")
alt_RDR                 = varQual_RDR  rEAD_PREC (fsLit "+++") 
reset_RDR               = varQual_RDR  rEAD_PREC (fsLit "reset")
prec_RDR                = varQual_RDR  rEAD_PREC (fsLit "prec")
525

Ian Lynagh's avatar
Ian Lynagh committed
526 527
showList_RDR, showList___RDR, showsPrec_RDR, showString_RDR,
    showSpace_RDR, showParen_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
528 529 530 531 532 533
showList_RDR            = varQual_RDR gHC_SHOW (fsLit "showList")
showList___RDR          = varQual_RDR gHC_SHOW (fsLit "showList__")
showsPrec_RDR           = varQual_RDR gHC_SHOW (fsLit "showsPrec") 
showString_RDR          = varQual_RDR gHC_SHOW (fsLit "showString")
showSpace_RDR           = varQual_RDR gHC_SHOW (fsLit "showSpace") 
showParen_RDR           = varQual_RDR gHC_SHOW (fsLit "showParen") 
534

Ian Lynagh's avatar
Ian Lynagh committed
535
typeOf_RDR, mkTypeRep_RDR, mkTyConRep_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
536 537 538
typeOf_RDR     = varQual_RDR tYPEABLE (fsLit "typeOf")
mkTypeRep_RDR  = varQual_RDR tYPEABLE (fsLit "mkTyConApp")
mkTyConRep_RDR = varQual_RDR tYPEABLE (fsLit "mkTyCon")
539

Ian Lynagh's avatar
Ian Lynagh committed
540
undefined_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
541
undefined_RDR = varQual_RDR gHC_ERR (fsLit "undefined")
542

543 544 545 546
error_RDR :: RdrName
error_RDR = varQual_RDR gHC_ERR (fsLit "error")

-- Old Generics (constructors and functions)
Ian Lynagh's avatar
Ian Lynagh committed
547
crossDataCon_RDR, inlDataCon_RDR, inrDataCon_RDR, genUnitDataCon_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
548 549 550 551
crossDataCon_RDR   = dataQual_RDR gHC_GENERICS (fsLit ":*:")
inlDataCon_RDR     = dataQual_RDR gHC_GENERICS (fsLit "Inl")
inrDataCon_RDR     = dataQual_RDR gHC_GENERICS (fsLit "Inr")
genUnitDataCon_RDR = dataQual_RDR gHC_GENERICS (fsLit "Unit")
552

553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597
-- Generics (constructors and functions)
u1DataCon_RDR, par1DataCon_RDR, rec1DataCon_RDR,
  k1DataCon_RDR, m1DataCon_RDR, l1DataCon_RDR, r1DataCon_RDR,
  prodDataCon_RDR, comp1DataCon_RDR, from0_RDR, from1_RDR,
  to0_RDR, to1_RDR, datatypeName_RDR, moduleName_RDR, conName_RDR,
  conFixity_RDR, conIsRecord_RDR, conIsTuple_RDR,
  noArityDataCon_RDR, arityDataCon_RDR,
  prefixDataCon_RDR, infixDataCon_RDR, leftAssocDataCon_RDR,
  rightAssocDataCon_RDR, notAssocDataCon_RDR :: RdrName

--v1DataCon_RDR    = dataQual_RDR gHC_GENERICS (fsLit "V1")
u1DataCon_RDR    = dataQual_RDR gHC_GENERICS (fsLit "U1")
par1DataCon_RDR  = dataQual_RDR gHC_GENERICS (fsLit "Par1")
rec1DataCon_RDR  = dataQual_RDR gHC_GENERICS (fsLit "Rec1")
k1DataCon_RDR    = dataQual_RDR gHC_GENERICS (fsLit "K1")
m1DataCon_RDR    = dataQual_RDR gHC_GENERICS (fsLit "M1")

l1DataCon_RDR     = dataQual_RDR gHC_GENERICS (fsLit "L1")
r1DataCon_RDR     = dataQual_RDR gHC_GENERICS (fsLit "R1")

prodDataCon_RDR   = dataQual_RDR gHC_GENERICS (fsLit ":*:")
comp1DataCon_RDR  = dataQual_RDR gHC_GENERICS (fsLit "Comp1")

from0_RDR = varQual_RDR gHC_GENERICS (fsLit "from0")
from1_RDR = varQual_RDR gHC_GENERICS (fsLit "from1")
to0_RDR   = varQual_RDR gHC_GENERICS (fsLit "to0")
to1_RDR   = varQual_RDR gHC_GENERICS (fsLit "to1")

datatypeName_RDR  = varQual_RDR gHC_GENERICS (fsLit "datatypeName")
moduleName_RDR    = varQual_RDR gHC_GENERICS (fsLit "moduleName")
selName_RDR       = varQual_RDR gHC_GENERICS (fsLit "selName")
conName_RDR       = varQual_RDR gHC_GENERICS (fsLit "conName")
conFixity_RDR     = varQual_RDR gHC_GENERICS (fsLit "conFixity")
conIsRecord_RDR   = varQual_RDR gHC_GENERICS (fsLit "conIsRecord")
conIsTuple_RDR    = varQual_RDR gHC_GENERICS (fsLit "conIsTuple")

noArityDataCon_RDR    = dataQual_RDR gHC_GENERICS (fsLit "NoArity")
arityDataCon_RDR      = dataQual_RDR gHC_GENERICS (fsLit "Arity")
prefixDataCon_RDR     = dataQual_RDR gHC_GENERICS (fsLit "Prefix")
infixDataCon_RDR      = dataQual_RDR gHC_GENERICS (fsLit "Infix")
leftAssocDataCon_RDR  = dataQual_RDR gHC_GENERICS (fsLit "LeftAssociative")
rightAssocDataCon_RDR = dataQual_RDR gHC_GENERICS (fsLit "RightAssociative")
notAssocDataCon_RDR   = dataQual_RDR gHC_GENERICS (fsLit "NotAssociative")


598 599 600 601 602 603 604
fmap_RDR, pure_RDR, ap_RDR, foldable_foldr_RDR, traverse_RDR :: RdrName
fmap_RDR 		= varQual_RDR gHC_BASE (fsLit "fmap")
pure_RDR 		= varQual_RDR cONTROL_APPLICATIVE (fsLit "pure")
ap_RDR 			= varQual_RDR cONTROL_APPLICATIVE (fsLit "<*>")
foldable_foldr_RDR 	= varQual_RDR dATA_FOLDABLE       (fsLit "foldr")
traverse_RDR 		= varQual_RDR dATA_TRAVERSABLE    (fsLit "traverse")

605
----------------------
Ian Lynagh's avatar
Ian Lynagh committed
606 607
varQual_RDR, tcQual_RDR, clsQual_RDR, dataQual_RDR
    :: Module -> FastString -> RdrName
608 609 610 611
varQual_RDR  mod str = mkOrig mod (mkOccNameFS varName str)
tcQual_RDR   mod str = mkOrig mod (mkOccNameFS tcName str)
clsQual_RDR  mod str = mkOrig mod (mkOccNameFS clsName str)
dataQual_RDR mod str = mkOrig mod (mkOccNameFS dataName str)
612
\end{code}
613

614 615
%************************************************************************
%*									*
616
\subsection{Known-key names}
617 618 619
%*									*
%************************************************************************

620
Many of these Names are not really "built in", but some parts of the
621 622
compiler (notably the deriving mechanism) need to mention their names,
and it's convenient to write them all down in one place.
623

624 625 626 627
--MetaHaskell Extension  add the constrs and the lower case case
-- guys as well (perhaps) e.g. see  trueDataConName	below


628
\begin{code}
629 630 631
wildCardName :: Name
wildCardName = mkSystemVarName wildCardKey (fsLit "wild")

Ian Lynagh's avatar
Ian Lynagh committed
632
runMainIOName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
633
runMainIOName = varQual gHC_TOP_HANDLER (fsLit "runMainIO") runMainKey
634

Ian Lynagh's avatar
Ian Lynagh committed
635
orderingTyConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
636
orderingTyConName = tcQual   gHC_ORDERING (fsLit "Ordering") orderingTyConKey
637

Ian Lynagh's avatar
Ian Lynagh committed
638
eitherTyConName, leftDataConName, rightDataConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
639 640 641
eitherTyConName	  = tcQual  dATA_EITHER (fsLit "Either") eitherTyConKey
leftDataConName   = conName dATA_EITHER (fsLit "Left")   leftDataConKey
rightDataConName  = conName dATA_EITHER (fsLit "Right")  rightDataConKey
642

643
-- Old Generics (types)
Ian Lynagh's avatar
Ian Lynagh committed
644
crossTyConName, plusTyConName, genUnitTyConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
645 646 647
crossTyConName     = tcQual   gHC_GENERICS (fsLit ":*:") crossTyConKey
plusTyConName      = tcQual   gHC_GENERICS (fsLit ":+:") plusTyConKey
genUnitTyConName   = tcQual   gHC_GENERICS (fsLit "Unit") genUnitTyConKey
648

649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683
-- Generics (types)
v1TyConName, u1TyConName, par1TyConName, rec1TyConName,
  k1TyConName, m1TyConName, sumTyConName, prodTyConName,
  compTyConName, rTyConName, pTyConName, dTyConName, 
  cTyConName, sTyConName, rec0TyConName, par0TyConName,
  d1TyConName, c1TyConName, s1TyConName, noSelTyConName,
  rep0TyConName, rep1TyConName :: Name

v1TyConName  = tcQual gHC_GENERICS (fsLit "V1") v1TyConKey
u1TyConName  = tcQual gHC_GENERICS (fsLit "U1") u1TyConKey
par1TyConName  = tcQual gHC_GENERICS (fsLit "Par1") par1TyConKey
rec1TyConName  = tcQual gHC_GENERICS (fsLit "Rec1") rec1TyConKey
k1TyConName  = tcQual gHC_GENERICS (fsLit "K1") k1TyConKey
m1TyConName  = tcQual gHC_GENERICS (fsLit "M1") m1TyConKey

sumTyConName    = tcQual gHC_GENERICS (fsLit ":+:") sumTyConKey
prodTyConName   = tcQual gHC_GENERICS (fsLit ":*:") prodTyConKey
compTyConName   = tcQual gHC_GENERICS (fsLit ":.:") compTyConKey

rTyConName  = tcQual gHC_GENERICS (fsLit "R") rTyConKey
pTyConName  = tcQual gHC_GENERICS (fsLit "P") pTyConKey
dTyConName  = tcQual gHC_GENERICS (fsLit "D") dTyConKey
cTyConName  = tcQual gHC_GENERICS (fsLit "C") cTyConKey
sTyConName  = tcQual gHC_GENERICS (fsLit "S") sTyConKey

rec0TyConName  = tcQual gHC_GENERICS (fsLit "Rec0") rec0TyConKey
par0TyConName  = tcQual gHC_GENERICS (fsLit "Par0") par0TyConKey
d1TyConName  = tcQual gHC_GENERICS (fsLit "D1") d1TyConKey
c1TyConName  = tcQual gHC_GENERICS (fsLit "C1") c1TyConKey
s1TyConName  = tcQual gHC_GENERICS (fsLit "S1") s1TyConKey
noSelTyConName = tcQual gHC_GENERICS (fsLit "NoSelector") noSelTyConKey

rep0TyConName = tcQual gHC_GENERICS (fsLit "Rep0") rep0TyConKey
rep1TyConName = tcQual gHC_GENERICS (fsLit "Rep1") rep1TyConKey

684
-- Base strings Strings
Ian Lynagh's avatar
Ian Lynagh committed
685 686
unpackCStringName, unpackCStringAppendName, unpackCStringFoldrName,
    unpackCStringUtf8Name, eqStringName, stringTyConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
687 688 689 690 691 692
unpackCStringName       = varQual gHC_BASE (fsLit "unpackCString#") unpackCStringIdKey
unpackCStringAppendName = varQual gHC_BASE (fsLit "unpackAppendCString#") unpackCStringAppendIdKey
unpackCStringFoldrName  = varQual gHC_BASE (fsLit "unpackFoldrCString#") unpackCStringFoldrIdKey
unpackCStringUtf8Name   = varQual gHC_BASE (fsLit "unpackCStringUtf8#") unpackCStringUtf8IdKey
eqStringName	 	= varQual gHC_BASE (fsLit "eqString")  eqStringIdKey
stringTyConName         = tcQual  gHC_BASE (fsLit "String") stringTyConKey
693

694
-- The 'inline' function
Ian Lynagh's avatar
Ian Lynagh committed
695
inlineIdName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
696
inlineIdName	 	= varQual gHC_MAGIC (fsLit "inline") inlineIdKey
697

698
-- Base classes (Eq, Ord, Functor)
Ian Lynagh's avatar
Ian Lynagh committed
699
eqClassName, eqName, ordClassName, geName, functorClassName :: Name
700 701 702 703
eqClassName	  = clsQual  gHC_CLASSES (fsLit "Eq")      eqClassKey
eqName		  = methName gHC_CLASSES (fsLit "==")      eqClassOpKey
ordClassName	  = clsQual  gHC_CLASSES (fsLit "Ord")     ordClassKey
geName		  = methName gHC_CLASSES (fsLit ">=")      geClassOpKey
Ian Lynagh's avatar
Ian Lynagh committed
704
functorClassName  = clsQual  gHC_BASE (fsLit "Functor") functorClassKey
705 706

-- Class Monad
Ian Lynagh's avatar
Ian Lynagh committed
707
monadClassName, thenMName, bindMName, returnMName, failMName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
708 709 710 711 712
monadClassName	   = clsQual  gHC_BASE (fsLit "Monad")  monadClassKey
thenMName	   = methName gHC_BASE (fsLit ">>")     thenMClassOpKey
bindMName	   = methName gHC_BASE (fsLit ">>=")    bindMClassOpKey
returnMName	   = methName gHC_BASE (fsLit "return") returnMClassOpKey
failMName	   = methName gHC_BASE (fsLit "fail")   failMClassOpKey
713

714 715 716 717 718 719
-- Classes (Applicative, Foldable, Traversable)
applicativeClassName, foldableClassName, traversableClassName :: Name
applicativeClassName  = clsQual  cONTROL_APPLICATIVE (fsLit "Applicative") applicativeClassKey
foldableClassName     = clsQual  dATA_FOLDABLE       (fsLit "Foldable")    foldableClassKey
traversableClassName  = clsQual  dATA_TRAVERSABLE    (fsLit "Traversable") traversableClassKey

720
-- Functions for GHC extensions
Ian Lynagh's avatar
Ian Lynagh committed
721
groupWithName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
722
groupWithName = varQual gHC_EXTS (fsLit "groupWith") groupWithIdKey
723

724
-- Random PrelBase functions
Ian Lynagh's avatar
Ian Lynagh committed
725
fromStringName, otherwiseIdName, foldrName, buildName, augmentName,
726
    mapName, appendName, assertName,
Ian Lynagh's avatar
Ian Lynagh committed
727
    breakpointName, breakpointCondName, breakpointAutoName,
728
    dollarName, opaqueTyConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
729 730 731 732 733
fromStringName = methName dATA_STRING (fsLit "fromString") fromStringClassOpKey
otherwiseIdName   = varQual gHC_BASE (fsLit "otherwise")  otherwiseIdKey
foldrName	  = varQual gHC_BASE (fsLit "foldr")      foldrIdKey
buildName	  = varQual gHC_BASE (fsLit "build")      buildIdKey
augmentName	  = varQual gHC_BASE (fsLit "augment")    augmentIdKey
734
mapName           = varQual gHC_BASE (fsLit "map")        mapIdKey
Ian Lynagh's avatar
Ian Lynagh committed
735
appendName	  = varQual gHC_BASE (fsLit "++")         appendIdKey
736
dollarName	  = varQual gHC_BASE (fsLit "$")          dollarIdKey
Ian Lynagh's avatar
Ian Lynagh committed
737 738 739 740 741
assertName        = varQual gHC_BASE (fsLit "assert")     assertIdKey
breakpointName    = varQual gHC_BASE (fsLit "breakpoint") breakpointIdKey
breakpointCondName= varQual gHC_BASE (fsLit "breakpointCond") breakpointCondIdKey
breakpointAutoName= varQual gHC_BASE (fsLit "breakpointAuto") breakpointAutoIdKey
opaqueTyConName   = tcQual  gHC_BASE (fsLit "Opaque")   opaqueTyConKey
mnislaih's avatar
mnislaih committed
742

Ian Lynagh's avatar
Ian Lynagh committed
743
breakpointJumpName :: Name
744 745 746
breakpointJumpName
    = mkInternalName
        breakpointJumpIdKey
Ian Lynagh's avatar
Ian Lynagh committed
747
        (mkOccNameFS varName (fsLit "breakpointJump"))
748
        noSrcSpan
Ian Lynagh's avatar
Ian Lynagh committed
749
breakpointCondJumpName :: Name
David Himmelstrup's avatar
David Himmelstrup committed
750 751 752
breakpointCondJumpName
    = mkInternalName
        breakpointCondJumpIdKey
Ian Lynagh's avatar
Ian Lynagh committed
753
        (mkOccNameFS varName (fsLit "breakpointCondJump"))
754
        noSrcSpan
Ian Lynagh's avatar
Ian Lynagh committed
755
breakpointAutoJumpName :: Name
mnislaih's avatar
mnislaih committed
756 757 758
breakpointAutoJumpName
    = mkInternalName
        breakpointAutoJumpIdKey
Ian Lynagh's avatar
Ian Lynagh committed
759
        (mkOccNameFS varName (fsLit "breakpointAutoJump"))
760
        noSrcSpan
761

762
-- PrelTup
Ian Lynagh's avatar
Ian Lynagh committed
763
fstName, sndName :: Name
764 765
fstName		  = varQual dATA_TUPLE (fsLit "fst") fstIdKey
sndName		  = varQual dATA_TUPLE (fsLit "snd") sndIdKey
766

767
-- Module GHC.Num
Ian Lynagh's avatar
Ian Lynagh committed
768
numClassName, fromIntegerName, minusName, negateName, plusIntegerName,
769
    timesIntegerName,
770
    integerTyConName, smallIntegerName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
771 772 773 774 775 776
numClassName	  = clsQual  gHC_NUM (fsLit "Num") numClassKey
fromIntegerName   = methName gHC_NUM (fsLit "fromInteger") fromIntegerClassOpKey
minusName	  = methName gHC_NUM (fsLit "-") minusClassOpKey
negateName	  = methName gHC_NUM (fsLit "negate") negateClassOpKey
plusIntegerName   = varQual  gHC_INTEGER (fsLit "plusInteger") plusIntegerIdKey
timesIntegerName  = varQual  gHC_INTEGER (fsLit "timesInteger") timesIntegerIdKey
777
integerTyConName  = tcQual   gHC_INTEGER_TYPE (fsLit "Integer") integerTyConKey
Ian Lynagh's avatar
Ian Lynagh committed
778
smallIntegerName = varQual gHC_INTEGER (fsLit "smallInteger") smallIntegerIdKey
779

780
-- GHC.Real types and classes
Ian Lynagh's avatar
Ian Lynagh committed
781 782
rationalTyConName, ratioTyConName, ratioDataConName, realClassName,
    integralClassName, realFracClassName, fractionalClassName,
783 784
    fromRationalName, toIntegerName, toRationalName, fromIntegralName,
    realToFracName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
785 786 787 788 789 790 791
rationalTyConName   = tcQual  gHC_REAL (fsLit "Rational") rationalTyConKey
ratioTyConName	    = tcQual  gHC_REAL (fsLit "Ratio") ratioTyConKey
ratioDataConName    = conName gHC_REAL (fsLit ":%") ratioDataConKey
realClassName	    = clsQual gHC_REAL (fsLit "Real") realClassKey
integralClassName   = clsQual gHC_REAL (fsLit "Integral") integralClassKey
realFracClassName   = clsQual gHC_REAL (fsLit "RealFrac") realFracClassKey
fractionalClassName = clsQual gHC_REAL (fsLit "Fractional") fractionalClassKey
792 793 794 795 796
fromRationalName    = methName gHC_REAL (fsLit "fromRational") fromRationalClassOpKey
toIntegerName       = methName gHC_REAL (fsLit "toInteger") toIntegerClassOpKey
toRationalName      = methName gHC_REAL (fsLit "toRational") toRationalClassOpKey
fromIntegralName    = varQual  gHC_REAL (fsLit "fromIntegral") fromIntegralIdKey
realToFracName      = varQual  gHC_REAL (fsLit "realToFrac") realToFracIdKey
797 798

-- PrelFloat classes
Ian Lynagh's avatar
Ian Lynagh committed
799
floatingClassName, realFloatClassName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
800 801
floatingClassName  = clsQual  gHC_FLOAT (fsLit "Floating") floatingClassKey
realFloatClassName = clsQual  gHC_FLOAT (fsLit "RealFloat") realFloatClassKey
802 803

-- Class Ix
Ian Lynagh's avatar
Ian Lynagh committed
804
ixClassName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
805
ixClassName = clsQual gHC_ARR (fsLit "Ix") ixClassKey
806

807
-- Class Typeable
Ian Lynagh's avatar
Ian Lynagh committed
808 809 810
typeableClassName, typeable1ClassName, typeable2ClassName,
    typeable3ClassName, typeable4ClassName, typeable5ClassName,
    typeable6ClassName, typeable7ClassName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
811 812 813 814 815 816 817 818
typeableClassName  = clsQual tYPEABLE (fsLit "Typeable") typeableClassKey
typeable1ClassName = clsQual tYPEABLE (fsLit "Typeable1") typeable1ClassKey
typeable2ClassName = clsQual tYPEABLE (fsLit "Typeable2") typeable2ClassKey
typeable3ClassName = clsQual tYPEABLE (fsLit "Typeable3") typeable3ClassKey
typeable4ClassName = clsQual tYPEABLE (fsLit "Typeable4") typeable4ClassKey
typeable5ClassName = clsQual tYPEABLE (fsLit "Typeable5") typeable5ClassKey
typeable6ClassName = clsQual tYPEABLE (fsLit "Typeable6") typeable6ClassKey
typeable7ClassName = clsQual tYPEABLE (fsLit "Typeable7") typeable7ClassKey
819

Ian Lynagh's avatar
Ian Lynagh committed
820
typeableClassNames :: [Name]
821 822 823 824 825
typeableClassNames = 	[ typeableClassName, typeable1ClassName, typeable2ClassName
		 	, typeable3ClassName, typeable4ClassName, typeable5ClassName
			, typeable6ClassName, typeable7ClassName ]

-- Class Data
Ian Lynagh's avatar
Ian Lynagh committed
826
dataClassName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
827
dataClassName = clsQual gENERICS (fsLit "Data") dataClassKey
828 829

-- Error module
Ian Lynagh's avatar
Ian Lynagh committed
830
assertErrorName    :: Name
831
assertErrorName	  = varQual gHC_IO_Exception (fsLit "assertError") assertErrorIdKey
832

833
-- Enum module (Enum, Bounded)
Ian Lynagh's avatar
Ian Lynagh committed
834 835
enumClassName, enumFromName, enumFromToName, enumFromThenName,
    enumFromThenToName, boundedClassName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
836 837 838 839 840 841
enumClassName 	   = clsQual gHC_ENUM (fsLit "Enum") enumClassKey
enumFromName	   = methName gHC_ENUM (fsLit "enumFrom") enumFromClassOpKey
enumFromToName	   = methName gHC_ENUM (fsLit "enumFromTo") enumFromToClassOpKey
enumFromThenName   = methName gHC_ENUM (fsLit "enumFromThen") enumFromThenClassOpKey
enumFromThenToName = methName gHC_ENUM (fsLit "enumFromThenTo") enumFromThenToClassOpKey
boundedClassName   = clsQual gHC_ENUM (fsLit "Bounded") boundedClassKey
842 843

-- List functions
Ian Lynagh's avatar
Ian Lynagh committed
844
concatName, filterName, zipName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
845 846 847
concatName	  = varQual gHC_LIST (fsLit "concat") concatIdKey
filterName	  = varQual gHC_LIST (fsLit "filter") filterIdKey
zipName	   	  = varQual gHC_LIST (fsLit "zip") zipIdKey
848

849
-- Class Show
Ian Lynagh's avatar
Ian Lynagh committed
850
showClassName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
851
showClassName	  = clsQual gHC_SHOW (fsLit "Show")       showClassKey
852 853

-- Class Read
Ian Lynagh's avatar
Ian Lynagh committed
854
readClassName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
855
readClassName	   = clsQual gHC_READ (fsLit "Read") readClassKey
856

857 858 859 860 861 862 863 864 865 866
-- Classes Representable0 and Representable1, Datatype, Constructor and Selector
rep0ClassName, rep1ClassName, datatypeClassName, constructorClassName,
  selectorClassName :: Name
rep0ClassName = clsQual gHC_GENERICS (fsLit "Representable0") rep0ClassKey
rep1ClassName = clsQual gHC_GENERICS (fsLit "Representable1") rep1ClassKey

datatypeClassName = clsQual gHC_GENERICS (fsLit "Datatype") datatypeClassKey
constructorClassName = clsQual gHC_GENERICS (fsLit "Constructor") constructorClassKey
selectorClassName = clsQual gHC_GENERICS (fsLit "Selector") selectorClassKey

chak's avatar
chak committed
867
-- parallel array types and functions
Ian Lynagh's avatar
Ian Lynagh committed
868 869
enumFromToPName, enumFromThenToPName, nullPName, lengthPName,
    singletonPName, replicatePName, mapPName, filterPName,
870
    zipPName, crossMapPName, indexPName, toPName,
871 872 873 874 875 876 877 878 879 880 881 882 883 884 885
    emptyPName, appPName :: PackageId -> Name
enumFromToPName     pkg = varQual (gHC_PARR pkg) (fsLit "enumFromToP")     enumFromToPIdKey
enumFromThenToPName pkg = varQual (gHC_PARR pkg) (fsLit "enumFromThenToP") enumFromThenToPIdKey
nullPName           pkg = varQual (gHC_PARR pkg) (fsLit "nullP")           nullPIdKey
lengthPName         pkg = varQual (gHC_PARR pkg) (fsLit "lengthP")         lengthPIdKey
singletonPName      pkg = varQual (gHC_PARR pkg) (fsLit "singletonP")      singletonPIdKey
replicatePName      pkg = varQual (gHC_PARR pkg) (fsLit "replicateP")      replicatePIdKey
mapPName            pkg = varQual (gHC_PARR pkg) (fsLit "mapP")            mapPIdKey
filterPName         pkg = varQual (gHC_PARR pkg) (fsLit "filterP")         filterPIdKey
zipPName            pkg = varQual (gHC_PARR pkg) (fsLit "zipP")            zipPIdKey
crossMapPName       pkg = varQual (gHC_PARR pkg) (fsLit "crossMapP")       crossMapPIdKey
indexPName          pkg = varQual (gHC_PARR pkg) (fsLit "!:")              indexPIdKey
toPName             pkg = varQual (gHC_PARR pkg) (fsLit "toP")             toPIdKey
emptyPName          pkg = varQual (gHC_PARR pkg) (fsLit "emptyP")          emptyPIdKey
appPName            pkg = varQual (gHC_PARR pkg) (fsLit "+:+")             appPIdKey
chak's avatar
chak committed
886

887
-- IO things
Ian Lynagh's avatar
Ian Lynagh committed
888 889
ioTyConName, ioDataConName, thenIOName, bindIOName, returnIOName,
    failIOName :: Name
890 891
ioTyConName	  = tcQual  gHC_TYPES (fsLit "IO") ioTyConKey
ioDataConName     = conName gHC_TYPES (fsLit "IO") ioDataConKey
892 893 894
thenIOName	  = varQual gHC_BASE (fsLit "thenIO") thenIOIdKey
bindIOName	  = varQual gHC_BASE (fsLit "bindIO") bindIOIdKey
returnIOName	  = varQual gHC_BASE (fsLit "returnIO") returnIOIdKey
895
failIOName	  = varQual gHC_IO (fsLit "failIO") failIOIdKey
896

897
-- IO things
Ian Lynagh's avatar
Ian Lynagh committed
898
printName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
899
printName	  = varQual sYSTEM_IO (fsLit "print") printIdKey
900

901
-- Int, Word, and Addr things
Ian Lynagh's avatar
Ian Lynagh committed
902
int8TyConName, int16TyConName, int32TyConName, int64TyConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
903 904 905 906
int8TyConName     = tcQual gHC_INT  (fsLit "Int8") int8TyConKey
int16TyConName    = tcQual gHC_INT  (fsLit "Int16") int16TyConKey
int32TyConName    = tcQual gHC_INT  (fsLit "Int32") int32TyConKey
int64TyConName    = tcQual gHC_INT  (fsLit "Int64") int64TyConKey
907

908
-- Word module
Ian Lynagh's avatar
Ian Lynagh committed
909 910
word8TyConName, word16TyConName, word32TyConName, word64TyConName,
    wordTyConName, wordDataConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
911 912 913 914 915 916
word8TyConName    = tcQual  gHC_WORD (fsLit "Word8")  word8TyConKey
word16TyConName   = tcQual  gHC_WORD (fsLit "Word16") word16TyConKey
word32TyConName   = tcQual  gHC_WORD (fsLit "Word32") word32TyConKey
word64TyConName   = tcQual  gHC_WORD (fsLit "Word64") word64TyConKey
wordTyConName     = tcQual  gHC_WORD (fsLit "Word")   wordTyConKey
wordDataConName   = conName gHC_WORD (fsLit "W#") wordDataConKey
917

918
-- PrelPtr module
Ian Lynagh's avatar
Ian Lynagh committed
919
ptrTyConName, funPtrTyConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
920 921
ptrTyConName	  = tcQual   gHC_PTR (fsLit "Ptr") ptrTyConKey
funPtrTyConName	  = tcQual   gHC_PTR (fsLit "FunPtr") funPtrTyConKey
922

chak's avatar
chak committed
923
-- Foreign objects and weak pointers
Ian Lynagh's avatar
Ian Lynagh committed
924
stablePtrTyConName, newStablePtrName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
925 926
stablePtrTyConName    = tcQual   gHC_STABLE (fsLit "StablePtr") stablePtrTyConKey
newStablePtrName      = varQual  gHC_STABLE (fsLit "newStablePtr") newStablePtrIdKey
927 928

-- PrelST module
Ian Lynagh's avatar
Ian Lynagh committed
929
runSTRepName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
930
runSTRepName	   = varQual gHC_ST  (fsLit "runSTRep") runSTRepIdKey
931

932
-- Recursive-do notation
Ian Lynagh's avatar
Ian Lynagh committed
933
monadFixClassName, mfixName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
934 935
monadFixClassName  = clsQual mONAD_FIX (fsLit "MonadFix") monadFixClassKey
mfixName	   = methName mONAD_FIX (fsLit "mfix") mfixIdKey
sof's avatar
sof committed
936

937
-- Arrow notation
Ian Lynagh's avatar
Ian Lynagh committed
938
arrAName, composeAName, firstAName, appAName, choiceAName, loopAName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
939 940 941 942 943 944
arrAName	   = varQual aRROW (fsLit "arr")	  arrAIdKey
composeAName	   = varQual gHC_DESUGAR (fsLit ">>>") composeAIdKey
firstAName	   = varQual aRROW (fsLit "first") firstAIdKey
appAName	   = varQual aRROW (fsLit "app")	  appAIdKey
choiceAName	   = varQual aRROW (fsLit "|||")	  choiceAIdKey
loopAName	   = varQual aRROW (fsLit "loop")  loopAIdKey
945

946 947 948 949
-- Annotation type checking
toAnnotationWrapperName :: Name
toAnnotationWrapperName = varQual gHC_DESUGAR (fsLit "toAnnotationWrapper") toAnnotationWrapperIdKey

950
-- Other classes, needed for type defaulting
Ian Lynagh's avatar
Ian Lynagh committed
951 952
monadPlusClassName, randomClassName, randomGenClassName,
    isStringClassName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
953 954 955 956
monadPlusClassName  = clsQual mONAD (fsLit "MonadPlus")  monadPlusClassKey
randomClassName     = clsQual rANDOM (fsLit "Random")    randomClassKey
randomGenClassName  = clsQual rANDOM (fsLit "RandomGen") randomGenClassKey
isStringClassName   = clsQual dATA_STRING (fsLit "IsString") isStringClassKey
957

sof's avatar
sof committed
958
-- dotnet interop
Ian Lynagh's avatar
Ian Lynagh committed
959
objectTyConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
960
objectTyConName	    = tcQual   dOTNET (fsLit "Object") objectTyConKey
961 962
	-- objectTyConName was "wTcQual", but that's gone now, and
	-- I can't see why it was wired in anyway...
Ian Lynagh's avatar
Ian Lynagh committed
963 964
unmarshalObjectName, marshalObjectName, marshalStringName,
    unmarshalStringName, checkDotnetResName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
965 966 967 968 969
unmarshalObjectName = varQual  dOTNET (fsLit "unmarshalObject") unmarshalObjectIdKey
marshalObjectName   = varQual  dOTNET (fsLit "marshalObject") marshalObjectIdKey
marshalStringName   = varQual  dOTNET (fsLit "marshalString") marshalStringIdKey
unmarshalStringName = varQual  dOTNET (fsLit "unmarshalString") unmarshalStringIdKey
checkDotnetResName  = varQual  dOTNET (fsLit "checkResult")     checkDotnetResNameIdKey
970 971 972 973 974 975 976 977
\end{code}

%************************************************************************
%*									*
\subsection{Local helpers}
%*									*
%************************************************************************

978
All these are original names; hence mkOrig
979

simonpj's avatar