PrelNames.lhs 77.3 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

9
10
 - ModuleNames for prelude modules,
        e.g.    pREL_BASE_Name :: ModuleName
11

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

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

20
 - Names for Ids, DataCons, TyCons and Classes that the compiler
Thomas Schilling's avatar
Thomas Schilling committed
21
   "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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
Note [Known-key names]
~~~~~~~~~~~~~~~~~~~~~~

It is *very* important that the compiler gives wired-in things and things with "known-key" names
the correct Uniques wherever they occur. We have to be careful about this in exactly two places:

  1. When we parse some source code, renaming the AST better yield an AST whose Names have the
     correct uniques

  2. When we read an interface file, the read-in gubbins better have the right uniques

This is accomplished through a combination of mechanisms:

  1. When parsing source code, the RdrName-decorated AST has some RdrNames which are Exact. These are
     wired-in RdrNames where the we could directly tell from the parsed syntax what Name to use. For
     example, when we parse a [] in a type we can just insert an Exact RdrName Name with the listTyConKey.

     Currently, I believe this is just an optimisation: it would be equally valid to just output Orig
     RdrNames that correctly record the module etc we expect the final Name to come from. However,
     were we to eliminate isTupleOcc_maybe it would become essential (see point 3).

  2. The knownKeyNames (which consist of the basicKnownKeyNames from the module, and those names reachable
     via the wired-in stuff from TysWiredIn) are used to initialise the "original name cache" in IfaceEnv.
     This initialization ensures that when the type checker or renamer (both of which use IfaceEnv) look up
     an original name (i.e. a pair of a Module and an OccName) for a known-key name they get the correct Unique.

     This is the most important mechanism for ensuring that known-key stuff gets the right Unique, and is why
     it is so important to place your known-key names in the appropriate lists.

  3. For "infinite families" of known-key names (i.e. tuples, Any tycons and implicit parameter TyCons), we
     have to be extra careful. Because there are an infinite number of these things, we cannot add them to
     the list of known-key names used to initialise the original name cache. Instead, we have to rely on
     never having to look them up in that cache.

     This is accomplished through a variety of mechanisms:

       a) The known infinite families of names are specially serialised by BinIface.putName, with that special treatment
          detected when we read back to ensure that we get back to the correct uniques.

       b) Most of the infinite families cannot occur in source code, so mechanism a) sufficies to ensure that they
          always have the right Unique. In particular, implicit param TyCon names, constraint tuples and Any TyCons
          cannot be mentioned by the user.

       c) Tuple TyCon/DataCon names have a special hack (isTupleOcc_maybe) that is used by the original name cache
          lookup routine to detect tuple names and give them the right Unique. You might think that this is unnecessary
          because tuple TyCon/DataCons are parsed as Exact RdrNames and *don't* appear as original names in interface files
          (because serialization gives them special treatment), so we will never look them up in the original name cache.

          However, there is a subtle reason why this is not the case: if you use setRdrNameSpace on an Exact RdrName
          it may be turned into an Orig RdrName. So if the original name was an Exact tuple Name we might end up with
          an Orig instead, which *will* lead to an original name cache query.
89
\begin{code}
90
module PrelNames (
91
92
93
94
95
96
97
98
        Unique, Uniquable(..), hasKey,  -- Re-exported for convenience

        -----------------------------------------------------------
        module PrelNames,       -- A huge bunch of (a) Names,  e.g. intTyConName
                                --                 (b) Uniques e.g. intTyConKey
                                --                 (c) Groups of classes and types
                                --                 (d) miscellaneous things
                                -- So many that we export them all
99
    ) where
100
101
102

#include "HsVersions.h"

103
import Module
Ian Lynagh's avatar
Ian Lynagh committed
104
import OccName
105
106
107
108
import RdrName
import Unique
import BasicTypes
import Name
109
import SrcLoc
110
import FastString
111
112
\end{code}

113

114
%************************************************************************
115
%*                                                                      *
116
\subsection{Local Names}
117
%*                                                                      *
118
119
120
121
122
%************************************************************************

This *local* name is used by the interactive stuff

\begin{code}
123
124
itName :: Unique -> SrcSpan -> Name
itName uniq loc = mkInternalName uniq (mkOccNameFS varName (fsLit "it")) loc
125
126
127
128
129
130
\end{code}

\begin{code}
-- mkUnboundName makes a place-holder Name; it shouldn't be looked at except possibly
-- during compiler debugging.
mkUnboundName :: RdrName -> Name
131
mkUnboundName rdr_name = mkInternalName unboundKey (rdrNameOcc rdr_name) noSrcSpan
132
133
134
135
136
137

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


138
%************************************************************************
139
%*                                                                      *
140
\subsection{Known key Names}
141
%*                                                                      *
142
143
%************************************************************************

144
This section tells what the compiler knows about the association of
145
146
names with uniques.  These ones are the *non* wired-in ones.  The
wired in ones are defined in TysWiredIn etc.
147

148
The names for DPH can come from one of multiple backend packages. At the point where
149
150
151
152
153
'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.

154
\begin{code}
155
156
basicKnownKeyNames :: [Name]
basicKnownKeyNames
157
 = genericTyConNames
158
 ++ typeableClassNames
159
 ++ dphKnownKeyNames dphSeqPackageId ++ dphKnownKeyNames dphParPackageId
160
161
162
163
164
165
166
 ++ [   -- Type constructors (synonyms especially)
        ioTyConName, ioDataConName,
        runMainIOName,
        rationalTyConName,
        stringTyConName,
        ratioDataConName,
        ratioTyConName,
167
        integerTyConName,
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191

        --  Classes.  *Must* include:
        --      classes that are grabbed by key (e.g., eqClassKey)
        --      classes in "Class.standardClassKeys" (quite a few)
        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
        dataClassName,
        isStringClassName,
        applicativeClassName,
        foldableClassName,
        traversableClassName,

        -- Numeric stuff
192
193
194
195
196
197
        negateName, minusName, geName, eqName,

        -- Conversion functions
        fromRationalName, fromIntegerName,
        toIntegerName, toRationalName,
        fromIntegralName, realToFracName,
198
199
200

        -- String stuff
        fromStringName,
201
202
203
204
205
206
207
208

        -- Enum stuff
        enumFromName, enumFromThenName,
        enumFromThenToName, enumFromToName,

        -- Monad stuff
        thenIOName, bindIOName, returnIOName, failIOName,
        failMName, bindMName, thenMName, returnMName,
209
        fmapName,
210

211
212
        -- MonadRec stuff
        mfixName,
213

214
215
216
        -- Arrow stuff
        arrAName, composeAName, firstAName,
        appAName, choiceAName, loopAName,
217

218
219
        -- Ix stuff
        ixClassName,
220

221
222
        -- Show stuff
        showClassName,
223

224
225
        -- Read stuff
        readClassName,
226

227
228
        -- Stable pointers
        newStablePtrName,
229

230
    -- GHC Extensions
231
        groupWithName,
232

233
234
235
        -- Strings and lists
        unpackCStringName,
        unpackCStringFoldrName, unpackCStringUtf8Name,
236

237
238
239
        -- List operations
        concatName, filterName, mapName,
        zipName, foldrName, buildName, augmentName, appendName,
240

241
        dollarName,         -- The ($) apply function
242

243
244
245
246
        -- FFI primitive types that are not wired-in.
        stablePtrTyConName, ptrTyConName, funPtrTyConName,
        int8TyConName, int16TyConName, int32TyConName, int64TyConName,
        wordTyConName, word8TyConName, word16TyConName, word32TyConName, word64TyConName,
247

248
249
250
        -- Others
        otherwiseIdName, inlineIdName,
        eqStringName, assertName, breakpointName, breakpointCondName,
251
        breakpointAutoName,  opaqueTyConName,
David Himmelstrup's avatar
David Himmelstrup committed
252
        assertErrorName, runSTRepName,
253
        printName, fstName, sndName,
254

255
        -- Integer
256
        integerTyConName, mkIntegerName,
257
        plusIntegerName, timesIntegerName, smallIntegerName,
258
259
260
261
        integerToWordName, integerToIntName, minusIntegerName,
        negateIntegerName, eqIntegerName, neqIntegerName,
        absIntegerName, signumIntegerName,
        leIntegerName, gtIntegerName, ltIntegerName, geIntegerName,
Ian Lynagh's avatar
Ian Lynagh committed
262
        compareIntegerName, quotRemIntegerName, divModIntegerName,
263
264
265
266
        gcdIntegerName, lcmIntegerName,
        andIntegerName, orIntegerName, xorIntegerName, complementIntegerName,
        shiftLIntegerName, shiftRIntegerName,

267
268
        -- MonadFix
        monadFixClassName, mfixName,
269

270
271
        -- Other classes
        randomClassName, randomGenClassName, monadPlusClassName,
272

273
        -- Annotation type checking
274
        toAnnotationWrapperName
275

276
277
278
        -- The Ordering type
        , orderingTyConName, ltDataConName, eqDataConName, gtDataConName

279
280
        -- The Either type
        , eitherTyConName, leftDataConName, rightDataConName
281

282
283
        -- Plugins
        , pluginTyConName
284
285
286
287
288
289
290
291
292

        -- dotnet interop
        , objectTyConName, marshalObjectName, unmarshalObjectName
        , marshalStringName, unmarshalStringName, checkDotnetResName

        -- Generics
        , genClassName, gen1ClassName
        , datatypeClassName, constructorClassName, selectorClassName

293
294
295
296
297
        -- Monad comprehensions
        , guardMName
        , liftMName
        , groupMName
        , mzipName
298
    ]
299

300
genericTyConNames :: [Name]
301
302
303
304
305
306
genericTyConNames = [
    v1TyConName, u1TyConName, par1TyConName, rec1TyConName,
    k1TyConName, m1TyConName, sumTyConName, prodTyConName,
    compTyConName, rTyConName, pTyConName, dTyConName,
    cTyConName, sTyConName, rec0TyConName, par0TyConName,
    d1TyConName, c1TyConName, s1TyConName, noSelTyConName,
307
    repTyConName, rep1TyConName
308
  ]
309
310
311
312
313
314
315
316

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

    ]
323
324
325
\end{code}


326
%************************************************************************
327
%*                                                                      *
328
\subsection{Module names}
329
%*                                                                      *
330
331
%************************************************************************

332
333

--MetaHaskell Extension Add a new module here
334
\begin{code}
Ian Lynagh's avatar
Ian Lynagh committed
335
pRELUDE :: Module
336
pRELUDE         = mkBaseModule_ pRELUDE_NAME
Ian Lynagh's avatar
Ian Lynagh committed
337

Ian Lynagh's avatar
Ian Lynagh committed
338
gHC_PRIM, gHC_TYPES, gHC_GENERICS,
Ian Lynagh's avatar
Ian Lynagh committed
339
    gHC_MAGIC,
340
    gHC_CLASSES, gHC_BASE, gHC_ENUM, gHC_CSTRING,
341
    gHC_SHOW, gHC_READ, gHC_NUM, gHC_INTEGER_TYPE, gHC_LIST,
342
    gHC_TUPLE, dATA_TUPLE, dATA_EITHER, dATA_STRING, dATA_FOLDABLE, dATA_TRAVERSABLE,
dterei's avatar
dterei committed
343
344
    gHC_CONC, gHC_IO, gHC_IO_Exception,
    gHC_ST, gHC_ARR, gHC_STABLE, gHC_PTR, gHC_ERR, gHC_REAL,
345
    gHC_FLOAT, gHC_TOP_HANDLER, sYSTEM_IO, dYNAMIC, tYPEABLE, tYPEABLE_INTERNAL, gENERICS,
346
347
348
    dOTNET, rEAD_PREC, lEX, gHC_INT, gHC_WORD, mONAD, mONAD_FIX, mONAD_GROUP, mONAD_ZIP,
    aRROW, cONTROL_APPLICATIVE, gHC_DESUGAR, rANDOM, gHC_EXTS,
    cONTROL_EXCEPTION_BASE :: Module
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
349

350
gHC_PRIM        = mkPrimModule (fsLit "GHC.Prim")   -- Primitive types and values
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
351
gHC_TYPES       = mkPrimModule (fsLit "GHC.Types")
352
353
354
355
356
357
358
359
360
361
gHC_GENERICS    = mkPrimModule (fsLit "GHC.Generics")
gHC_MAGIC       = mkPrimModule (fsLit "GHC.Magic")
gHC_CSTRING     = mkPrimModule (fsLit "GHC.CString")
gHC_CLASSES     = mkPrimModule (fsLit "GHC.Classes")

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")
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
362
gHC_INTEGER_TYPE= mkIntegerModule (fsLit "GHC.Integer.Type")
363
364
365
gHC_LIST        = mkBaseModule (fsLit "GHC.List")
gHC_TUPLE       = mkPrimModule (fsLit "GHC.Tuple")
dATA_TUPLE      = mkBaseModule (fsLit "Data.Tuple")
366
367
368
dATA_EITHER     = mkBaseModule (fsLit "Data.Either")
dATA_STRING     = mkBaseModule (fsLit "Data.String")
dATA_FOLDABLE   = mkBaseModule (fsLit "Data.Foldable")
369
dATA_TRAVERSABLE= mkBaseModule (fsLit "Data.Traversable")
370
371
gHC_CONC        = mkBaseModule (fsLit "GHC.Conc")
gHC_IO          = mkBaseModule (fsLit "GHC.IO")
372
gHC_IO_Exception = mkBaseModule (fsLit "GHC.IO.Exception")
373
374
375
376
377
378
379
380
381
382
gHC_ST          = mkBaseModule (fsLit "GHC.ST")
gHC_ARR         = mkBaseModule (fsLit "GHC.Arr")
gHC_STABLE      = mkBaseModule (fsLit "GHC.Stable")
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")
383
384
tYPEABLE        = mkBaseModule (fsLit "Data.Typeable")
tYPEABLE_INTERNAL = mkBaseModule (fsLit "Data.Typeable.Internal")
385
gENERICS        = mkBaseModule (fsLit "Data.Data")
386
387
388
389
390
391
392
dOTNET          = mkBaseModule (fsLit "GHC.Dotnet")
rEAD_PREC       = mkBaseModule (fsLit "Text.ParserCombinators.ReadPrec")
lEX             = mkBaseModule (fsLit "Text.Read.Lex")
gHC_INT         = mkBaseModule (fsLit "GHC.Int")
gHC_WORD        = mkBaseModule (fsLit "GHC.Word")
mONAD           = mkBaseModule (fsLit "Control.Monad")
mONAD_FIX       = mkBaseModule (fsLit "Control.Monad.Fix")
393
394
mONAD_GROUP     = mkBaseModule (fsLit "Control.Monad.Group")
mONAD_ZIP       = mkBaseModule (fsLit "Control.Monad.Zip")
395
aRROW           = mkBaseModule (fsLit "Control.Arrow")
396
cONTROL_APPLICATIVE = mkBaseModule (fsLit "Control.Applicative")
Ian Lynagh's avatar
Ian Lynagh committed
397
gHC_DESUGAR = mkBaseModule (fsLit "GHC.Desugar")
398
399
rANDOM          = mkBaseModule (fsLit "System.Random")
gHC_EXTS        = mkBaseModule (fsLit "GHC.Exts")
400
cONTROL_EXCEPTION_BASE = mkBaseModule (fsLit "Control.Exception.Base")
Simon Marlow's avatar
Simon Marlow committed
401

402
403
404
405
406
407
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
408
mAIN, rOOT_MAIN :: Module
409
410
mAIN            = mkMainModule_ mAIN_NAME
rOOT_MAIN       = mkMainModule (fsLit ":Main") -- Root module for initialisation
Simon Marlow's avatar
Simon Marlow committed
411

412
413
414
415
        -- The ':xxx' makes a module name that the user can never
        -- 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.
416
iNTERACTIVE :: Module
Ian Lynagh's avatar
Ian Lynagh committed
417
iNTERACTIVE    = mkMainModule (fsLit ":Interactive")
Simon Marlow's avatar
Simon Marlow committed
418

Ian Lynagh's avatar
Ian Lynagh committed
419
pRELUDE_NAME, mAIN_NAME :: ModuleName
Ian Lynagh's avatar
Ian Lynagh committed
420
421
pRELUDE_NAME   = mkModuleNameFS (fsLit "Prelude")
mAIN_NAME      = mkModuleNameFS (fsLit "Main")
Simon Marlow's avatar
Simon Marlow committed
422

Ian Lynagh's avatar
Ian Lynagh committed
423
424
425
426
427
428
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
429
430
431
432
433
434
mkBaseModule :: FastString -> Module
mkBaseModule m = mkModule basePackageId (mkModuleNameFS m)

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

435
436
437
438
439
440
mkThisGhcModule :: FastString -> Module
mkThisGhcModule m = mkModule thisGhcPackageId (mkModuleNameFS m)

mkThisGhcModule_ :: ModuleName -> Module
mkThisGhcModule_ m = mkModule thisGhcPackageId m

Simon Marlow's avatar
Simon Marlow committed
441
442
mkMainModule :: FastString -> Module
mkMainModule m = mkModule mainPackageId (mkModuleNameFS m)
443

Simon Marlow's avatar
Simon Marlow committed
444
445
mkMainModule_ :: ModuleName -> Module
mkMainModule_ m = mkModule mainPackageId m
446
447
448
\end{code}

%************************************************************************
449
%*                                                                      *
450
\subsection{Constructing the names of tuples
451
%*                                                                      *
452
453
454
%************************************************************************

\begin{code}
batterseapower's avatar
batterseapower committed
455
456
mkTupleModule :: TupleSort -> Arity -> Module
mkTupleModule BoxedTuple   _ = gHC_TUPLE
457
mkTupleModule ConstraintTuple    _ = gHC_TUPLE
batterseapower's avatar
batterseapower committed
458
mkTupleModule UnboxedTuple _ = gHC_PRIM
459
460
461
\end{code}


462
%************************************************************************
463
464
465
%*                                                                      *
                        RdrNames
%*                                                                      *
466
467
468
%************************************************************************

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

474
forall_tv_RDR, dot_tv_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
475
476
forall_tv_RDR = mkUnqual tvName (fsLit "forall")
dot_tv_RDR    = mkUnqual tvName (fsLit ".")
477

Ian Lynagh's avatar
Ian Lynagh committed
478
479
eq_RDR, ge_RDR, ne_RDR, le_RDR, lt_RDR, gt_RDR, compare_RDR,
    ltTag_RDR, eqTag_RDR, gtTag_RDR :: RdrName
480
481
482
483
484
485
486
eq_RDR                  = nameRdrName eqName
ge_RDR                  = nameRdrName geName
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
487
488
489
ltTag_RDR               = dataQual_RDR gHC_TYPES (fsLit "LT")
eqTag_RDR               = dataQual_RDR gHC_TYPES (fsLit "EQ")
gtTag_RDR               = dataQual_RDR gHC_TYPES (fsLit "GT")
490

Ian Lynagh's avatar
Ian Lynagh committed
491
492
eqClass_RDR, numClass_RDR, ordClass_RDR, enumClass_RDR, monadClass_RDR
    :: RdrName
493
494
495
496
497
eqClass_RDR             = nameRdrName eqClassName
numClass_RDR            = nameRdrName numClassName
ordClass_RDR            = nameRdrName ordClassName
enumClass_RDR           = nameRdrName enumClassName
monadClass_RDR          = nameRdrName monadClassName
498

Ian Lynagh's avatar
Ian Lynagh committed
499
map_RDR, append_RDR :: RdrName
500
501
map_RDR                 = varQual_RDR gHC_BASE (fsLit "map")
append_RDR              = varQual_RDR gHC_BASE (fsLit "++")
502

Ian Lynagh's avatar
Ian Lynagh committed
503
foldr_RDR, build_RDR, returnM_RDR, bindM_RDR, failM_RDR :: RdrName
504
505
506
507
508
foldr_RDR               = nameRdrName foldrName
build_RDR               = nameRdrName buildName
returnM_RDR             = nameRdrName returnMName
bindM_RDR               = nameRdrName bindMName
failM_RDR               = nameRdrName failMName
509

Ian Lynagh's avatar
Ian Lynagh committed
510
left_RDR, right_RDR :: RdrName
511
512
left_RDR                = nameRdrName leftDataConName
right_RDR               = nameRdrName rightDataConName
513

Ian Lynagh's avatar
Ian Lynagh committed
514
fromEnum_RDR, toEnum_RDR :: RdrName
515
516
fromEnum_RDR            = varQual_RDR gHC_ENUM (fsLit "fromEnum")
toEnum_RDR              = varQual_RDR gHC_ENUM (fsLit "toEnum")
517

Ian Lynagh's avatar
Ian Lynagh committed
518
enumFrom_RDR, enumFromTo_RDR, enumFromThen_RDR, enumFromThenTo_RDR :: RdrName
519
520
521
522
enumFrom_RDR            = nameRdrName enumFromName
enumFromTo_RDR          = nameRdrName enumFromToName
enumFromThen_RDR        = nameRdrName enumFromThenName
enumFromThenTo_RDR      = nameRdrName enumFromThenToName
523

Ian Lynagh's avatar
Ian Lynagh committed
524
ratioDataCon_RDR, plusInteger_RDR, timesInteger_RDR :: RdrName
525
526
527
ratioDataCon_RDR        = nameRdrName ratioDataConName
plusInteger_RDR         = nameRdrName plusIntegerName
timesInteger_RDR        = nameRdrName timesIntegerName
528

Ian Lynagh's avatar
Ian Lynagh committed
529
ioDataCon_RDR :: RdrName
530
ioDataCon_RDR           = nameRdrName ioDataConName
531

Ian Lynagh's avatar
Ian Lynagh committed
532
533
eqString_RDR, unpackCString_RDR, unpackCStringFoldr_RDR,
    unpackCStringUtf8_RDR :: RdrName
534
535
536
537
eqString_RDR            = nameRdrName eqStringName
unpackCString_RDR       = nameRdrName unpackCStringName
unpackCStringFoldr_RDR  = nameRdrName unpackCStringFoldrName
unpackCStringUtf8_RDR   = nameRdrName unpackCStringUtf8Name
538

Ian Lynagh's avatar
Ian Lynagh committed
539
newStablePtr_RDR, wordDataCon_RDR :: RdrName
540
541
newStablePtr_RDR        = nameRdrName newStablePtrName
wordDataCon_RDR         = dataQual_RDR gHC_WORD (fsLit "W#")
542

Ian Lynagh's avatar
Ian Lynagh committed
543
bindIO_RDR, returnIO_RDR :: RdrName
544
545
bindIO_RDR              = nameRdrName bindIOName
returnIO_RDR            = nameRdrName returnIOName
546

Ian Lynagh's avatar
Ian Lynagh committed
547
fromInteger_RDR, fromRational_RDR, minus_RDR, times_RDR, plus_RDR :: RdrName
548
549
550
551
fromInteger_RDR         = nameRdrName fromIntegerName
fromRational_RDR        = nameRdrName fromRationalName
minus_RDR               = nameRdrName minusName
times_RDR               = varQual_RDR  gHC_NUM (fsLit "*")
Ian Lynagh's avatar
Ian Lynagh committed
552
plus_RDR                = varQual_RDR gHC_NUM (fsLit "+")
Simon Marlow's avatar
Simon Marlow committed
553

Ian Lynagh's avatar
Ian Lynagh committed
554
fromString_RDR :: RdrName
555
fromString_RDR          = nameRdrName fromStringName
556

Ian Lynagh's avatar
Ian Lynagh committed
557
compose_RDR :: RdrName
558
compose_RDR             = varQual_RDR gHC_BASE (fsLit ".")
Simon Marlow's avatar
Simon Marlow committed
559

Ian Lynagh's avatar
Ian Lynagh committed
560
not_RDR, getTag_RDR, succ_RDR, pred_RDR, minBound_RDR, maxBound_RDR,
561
    and_RDR, range_RDR, inRange_RDR, index_RDR,
Ian Lynagh's avatar
Ian Lynagh committed
562
    unsafeIndex_RDR, unsafeRangeSize_RDR :: RdrName
563
564
565
566
and_RDR                 = varQual_RDR gHC_CLASSES (fsLit "&&")
not_RDR                 = varQual_RDR gHC_CLASSES (fsLit "not")
getTag_RDR              = varQual_RDR gHC_BASE (fsLit "getTag")
succ_RDR                = varQual_RDR gHC_ENUM (fsLit "succ")
Ian Lynagh's avatar
Ian Lynagh committed
567
568
569
570
571
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")
572
573
574
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
575

Ian Lynagh's avatar
Ian Lynagh committed
576
577
readList_RDR, readListDefault_RDR, readListPrec_RDR, readListPrecDefault_RDR,
    readPrec_RDR, parens_RDR, choose_RDR, lexP_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
578
579
580
581
582
583
584
585
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")
586

Ian Lynagh's avatar
Ian Lynagh committed
587
punc_RDR, ident_RDR, symbol_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
588
589
590
punc_RDR                = dataQual_RDR lEX (fsLit "Punc")
ident_RDR               = dataQual_RDR lEX (fsLit "Ident")
symbol_RDR              = dataQual_RDR lEX (fsLit "Symbol")
591

Ian Lynagh's avatar
Ian Lynagh committed
592
step_RDR, alt_RDR, reset_RDR, prec_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
593
step_RDR                = varQual_RDR  rEAD_PREC (fsLit "step")
594
alt_RDR                 = varQual_RDR  rEAD_PREC (fsLit "+++")
Ian Lynagh's avatar
Ian Lynagh committed
595
596
reset_RDR               = varQual_RDR  rEAD_PREC (fsLit "reset")
prec_RDR                = varQual_RDR  rEAD_PREC (fsLit "prec")
597

Ian Lynagh's avatar
Ian Lynagh committed
598
599
showList_RDR, showList___RDR, showsPrec_RDR, showString_RDR,
    showSpace_RDR, showParen_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
600
601
showList_RDR            = varQual_RDR gHC_SHOW (fsLit "showList")
showList___RDR          = varQual_RDR gHC_SHOW (fsLit "showList__")
602
showsPrec_RDR           = varQual_RDR gHC_SHOW (fsLit "showsPrec")
Ian Lynagh's avatar
Ian Lynagh committed
603
showString_RDR          = varQual_RDR gHC_SHOW (fsLit "showString")
604
605
showSpace_RDR           = varQual_RDR gHC_SHOW (fsLit "showSpace")
showParen_RDR           = varQual_RDR gHC_SHOW (fsLit "showParen")
606

607
typeOf_RDR, mkTyCon_RDR, mkTyConApp_RDR :: RdrName
608
typeOf_RDR     = varQual_RDR tYPEABLE_INTERNAL (fsLit "typeOf")
609
mkTyCon_RDR    = varQual_RDR tYPEABLE_INTERNAL (fsLit "mkTyCon")
610
mkTyConApp_RDR = varQual_RDR tYPEABLE_INTERNAL (fsLit "mkTyConApp")
611

Ian Lynagh's avatar
Ian Lynagh committed
612
undefined_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
613
undefined_RDR = varQual_RDR gHC_ERR (fsLit "undefined")
614

615
616
617
618
619
620
error_RDR :: RdrName
error_RDR = varQual_RDR gHC_ERR (fsLit "error")

-- Generics (constructors and functions)
u1DataCon_RDR, par1DataCon_RDR, rec1DataCon_RDR,
  k1DataCon_RDR, m1DataCon_RDR, l1DataCon_RDR, r1DataCon_RDR,
621
622
  prodDataCon_RDR, comp1DataCon_RDR, from_RDR, from1_RDR,
  to_RDR, to1_RDR, datatypeName_RDR, moduleName_RDR, conName_RDR,
623
  conFixity_RDR, conIsRecord_RDR,
624
  noArityDataCon_RDR, arityDataCon_RDR, selName_RDR,
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
  prefixDataCon_RDR, infixDataCon_RDR, leftAssocDataCon_RDR,
  rightAssocDataCon_RDR, notAssocDataCon_RDR :: RdrName

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")

640
from_RDR  = varQual_RDR gHC_GENERICS (fsLit "from")
641
from1_RDR = varQual_RDR gHC_GENERICS (fsLit "from1")
642
to_RDR    = varQual_RDR gHC_GENERICS (fsLit "to")
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
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")

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")


661
fmap_RDR, pure_RDR, ap_RDR, foldable_foldr_RDR, traverse_RDR :: RdrName
662
663
664
665
666
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")
667

668
----------------------
Ian Lynagh's avatar
Ian Lynagh committed
669
670
varQual_RDR, tcQual_RDR, clsQual_RDR, dataQual_RDR
    :: Module -> FastString -> RdrName
671
672
673
674
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)
675
\end{code}
676

677
%************************************************************************
678
%*                                                                      *
679
\subsection{Known-key names}
680
%*                                                                      *
681
682
%************************************************************************

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

687
--MetaHaskell Extension  add the constrs and the lower case case
688
-- guys as well (perhaps) e.g. see  trueDataConName     below
689
690


691
\begin{code}
692
693
694
wildCardName :: Name
wildCardName = mkSystemVarName wildCardKey (fsLit "wild")

Ian Lynagh's avatar
Ian Lynagh committed
695
runMainIOName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
696
runMainIOName = varQual gHC_TOP_HANDLER (fsLit "runMainIO") runMainKey
697

698
orderingTyConName, ltDataConName, eqDataConName, gtDataConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
699
700
701
702
orderingTyConName = tcQual   gHC_TYPES (fsLit "Ordering") orderingTyConKey
ltDataConName = conName gHC_TYPES (fsLit "LT") ltDataConKey
eqDataConName = conName gHC_TYPES (fsLit "EQ") eqDataConKey
gtDataConName = conName gHC_TYPES (fsLit "GT") gtDataConKey
Ian Lynagh's avatar
Ian Lynagh committed
703

Ian Lynagh's avatar
Ian Lynagh committed
704
eitherTyConName, leftDataConName, rightDataConName :: Name
705
eitherTyConName   = tcQual  dATA_EITHER (fsLit "Either") eitherTyConKey
Ian Lynagh's avatar
Ian Lynagh committed
706
707
leftDataConName   = conName dATA_EITHER (fsLit "Left")   leftDataConKey
rightDataConName  = conName dATA_EITHER (fsLit "Right")  rightDataConKey
708

709
710
711
-- Generics (types)
v1TyConName, u1TyConName, par1TyConName, rec1TyConName,
  k1TyConName, m1TyConName, sumTyConName, prodTyConName,
712
  compTyConName, rTyConName, pTyConName, dTyConName,
713
714
  cTyConName, sTyConName, rec0TyConName, par0TyConName,
  d1TyConName, c1TyConName, s1TyConName, noSelTyConName,
715
  repTyConName, rep1TyConName :: Name
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740

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

741
repTyConName  = tcQual gHC_GENERICS (fsLit "Rep")  repTyConKey
742
743
rep1TyConName = tcQual gHC_GENERICS (fsLit "Rep1") rep1TyConKey

744
-- Base strings Strings
Ian Lynagh's avatar
Ian Lynagh committed
745
unpackCStringName, unpackCStringFoldrName,
Ian Lynagh's avatar
Ian Lynagh committed
746
    unpackCStringUtf8Name, eqStringName, stringTyConName :: Name
747
748
749
unpackCStringName       = varQual gHC_CSTRING (fsLit "unpackCString#") unpackCStringIdKey
unpackCStringFoldrName  = varQual gHC_CSTRING (fsLit "unpackFoldrCString#") unpackCStringFoldrIdKey
unpackCStringUtf8Name   = varQual gHC_CSTRING (fsLit "unpackCStringUtf8#") unpackCStringUtf8IdKey
750
eqStringName            = varQual gHC_BASE (fsLit "eqString")  eqStringIdKey
Ian Lynagh's avatar
Ian Lynagh committed
751
stringTyConName         = tcQual  gHC_BASE (fsLit "String") stringTyConKey
752

753
-- The 'inline' function
Ian Lynagh's avatar
Ian Lynagh committed
754
inlineIdName :: Name
755
inlineIdName            = varQual gHC_MAGIC (fsLit "inline") inlineIdKey
756

757
758
759
760
-- The 'undefined' function. Used by supercompilation.
undefinedName :: Name
undefinedName = varQual gHC_ERR (fsLit "undefined") undefinedKey

761
-- Base classes (Eq, Ord, Functor)
762
fmapName, eqClassName, eqName, ordClassName, geName, functorClassName :: Name
763
764
765
766
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
767
functorClassName  = clsQual  gHC_BASE (fsLit "Functor") functorClassKey
768
fmapName          = methName gHC_BASE (fsLit "fmap")    fmapClassOpKey
769
770

-- Class Monad
Ian Lynagh's avatar
Ian Lynagh committed
771
monadClassName, thenMName, bindMName, returnMName, failMName :: Name
772
773
774
775
776
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
777

778
779
780
781
782
783
-- 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

784
-- Functions for GHC extensions
Ian Lynagh's avatar
Ian Lynagh committed
785
groupWithName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
786
groupWithName = varQual gHC_EXTS (fsLit "groupWith") groupWithIdKey
787

788
-- Random PrelBase functions
Ian Lynagh's avatar
Ian Lynagh committed
789
fromStringName, otherwiseIdName, foldrName, buildName, augmentName,
790
    mapName, appendName, assertName,
Ian Lynagh's avatar
Ian Lynagh committed
791
    breakpointName, breakpointCondName, breakpointAutoName,
792
    dollarName, opaqueTyConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
793
794
fromStringName = methName dATA_STRING (fsLit "fromString") fromStringClassOpKey
otherwiseIdName   = varQual gHC_BASE (fsLit "otherwise")  otherwiseIdKey
795
796
797
foldrName         = varQual gHC_BASE (fsLit "foldr")      foldrIdKey
buildName         = varQual gHC_BASE (fsLit "build")      buildIdKey
augmentName       = varQual gHC_BASE (fsLit "augment")    augmentIdKey
798
mapName           = varQual gHC_BASE (fsLit "map")        mapIdKey
799
800
appendName        = varQual gHC_BASE (fsLit "++")         appendIdKey
dollarName        = varQual gHC_BASE (fsLit "$")          dollarIdKey
Ian Lynagh's avatar
Ian Lynagh committed
801
802
803
804
805
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
806

Ian Lynagh's avatar
Ian Lynagh committed
807
breakpointJumpName :: Name
808
809
810
breakpointJumpName
    = mkInternalName
        breakpointJumpIdKey
Ian Lynagh's avatar
Ian Lynagh committed
811
        (mkOccNameFS varName (fsLit "breakpointJump"))
812
        noSrcSpan
Ian Lynagh's avatar
Ian Lynagh committed
813
breakpointCondJumpName :: Name
David Himmelstrup's avatar
David Himmelstrup committed
814
815
816
breakpointCondJumpName
    = mkInternalName
        breakpointCondJumpIdKey
Ian Lynagh's avatar
Ian Lynagh committed
817
        (mkOccNameFS varName (fsLit "breakpointCondJump"))
818
        noSrcSpan
Ian Lynagh's avatar
Ian Lynagh committed
819
breakpointAutoJumpName :: Name
mnislaih's avatar
mnislaih committed
820
821
822
breakpointAutoJumpName
    = mkInternalName
        breakpointAutoJumpIdKey
Ian Lynagh's avatar
Ian Lynagh committed
823
        (mkOccNameFS varName (fsLit "breakpointAutoJump"))
824
        noSrcSpan
825

826
-- PrelTup
Ian Lynagh's avatar
Ian Lynagh committed
827
fstName, sndName :: Name
828
829
fstName           = varQual dATA_TUPLE (fsLit "fst") fstIdKey
sndName           = varQual dATA_TUPLE (fsLit "snd") sndIdKey
830

831
-- Module GHC.Num
832
numClassName, fromIntegerName, minusName, negateName :: Name
833
numClassName      = clsQual  gHC_NUM (fsLit "Num") numClassKey
Ian Lynagh's avatar
Ian Lynagh committed
834
fromIntegerName   = methName gHC_NUM (fsLit "fromInteger") fromIntegerClassOpKey
835
836
minusName         = methName gHC_NUM (fsLit "-") minusClassOpKey
negateName        = methName gHC_NUM (fsLit "negate") negateClassOpKey
837

838
839
integerTyConName, mkIntegerName,
    plusIntegerName, timesIntegerName, smallIntegerName,
840
841
842
843
    integerToWordName, integerToIntName, minusIntegerName,
    negateIntegerName, eqIntegerName, neqIntegerName,
    absIntegerName, signumIntegerName,
    leIntegerName, gtIntegerName, ltIntegerName, geIntegerName,
Ian Lynagh's avatar
Ian Lynagh committed
844
    compareIntegerName, quotRemIntegerName, divModIntegerName,
845
846
847
    gcdIntegerName, lcmIntegerName,
    andIntegerName, orIntegerName, xorIntegerName, complementIntegerName,
    shiftLIntegerName, shiftRIntegerName :: Name
848
849
integerTyConName      = tcQual  gHC_INTEGER_TYPE (fsLit "Integer")           integerTyConKey
mkIntegerName         = varQual gHC_INTEGER_TYPE (fsLit "mkInteger")         mkIntegerIdKey
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
plusIntegerName       = varQual gHC_INTEGER_TYPE (fsLit "plusInteger")       plusIntegerIdKey
timesIntegerName      = varQual gHC_INTEGER_TYPE (fsLit "timesInteger")      timesIntegerIdKey
smallIntegerName      = varQual gHC_INTEGER_TYPE (fsLit "smallInteger")      smallIntegerIdKey
integerToWordName     = varQual gHC_INTEGER_TYPE (fsLit "integerToWord")     integerToWordIdKey
integerToIntName      = varQual gHC_INTEGER_TYPE (fsLit "integerToInt")      integerToIntIdKey
minusIntegerName      = varQual gHC_INTEGER_TYPE (fsLit "minusInteger")      minusIntegerIdKey
negateIntegerName     = varQual gHC_INTEGER_TYPE (fsLit "negateInteger")     negateIntegerIdKey
eqIntegerName         = varQual gHC_INTEGER_TYPE (fsLit "eqInteger")         eqIntegerIdKey
neqIntegerName        = varQual gHC_INTEGER_TYPE (fsLit "neqInteger")        neqIntegerIdKey
absIntegerName        = varQual gHC_INTEGER_TYPE (fsLit "absInteger")        absIntegerIdKey
signumIntegerName     = varQual gHC_INTEGER_TYPE (fsLit "signumInteger")     signumIntegerIdKey
leIntegerName         = varQual gHC_INTEGER_TYPE (fsLit "leInteger")         leIntegerIdKey
gtIntegerName         = varQual gHC_INTEGER_TYPE (fsLit "gtInteger")         gtIntegerIdKey
ltIntegerName         = varQual gHC_INTEGER_TYPE (fsLit "ltInteger")         ltIntegerIdKey
geIntegerName         = varQual gHC_INTEGER_TYPE (fsLit "geInteger")         geIntegerIdKey
compareIntegerName    = varQual gHC_INTEGER_TYPE (fsLit "compareInteger")    compareIntegerIdKey
Ian Lynagh's avatar
Ian Lynagh committed
866
867
quotRemIntegerName    = varQual gHC_INTEGER_TYPE (fsLit "quotRemInteger")    quotRemIntegerIdKey
divModIntegerName     = varQual gHC_INTEGER_TYPE (fsLit "divModInteger")     divModIntegerIdKey
868
869
870
871
872
873
874
875
gcdIntegerName        = varQual gHC_INTEGER_TYPE (fsLit "gcdInteger")        gcdIntegerIdKey
lcmIntegerName        = varQual gHC_INTEGER_TYPE (fsLit "lcmInteger")        lcmIntegerIdKey
andIntegerName        = varQual gHC_INTEGER_TYPE (fsLit "andInteger")        andIntegerIdKey
orIntegerName         = varQual gHC_INTEGER_TYPE (fsLit "orInteger")         orIntegerIdKey
xorIntegerName        = varQual gHC_INTEGER_TYPE (fsLit "xorInteger")        xorIntegerIdKey
complementIntegerName = varQual gHC_INTEGER_TYPE (fsLit "complementInteger") complementIntegerIdKey
shiftLIntegerName     = varQual gHC_INTEGER_TYPE (fsLit "shiftLInteger")     shiftLIntegerIdKey
shiftRIntegerName     = varQual gHC_INTEGER_TYPE (fsLit "shiftRInteger")     shiftRIntegerIdKey
876

877
-- GHC.Real types and classes
Ian Lynagh's avatar
Ian Lynagh committed
878
879
rationalTyConName, ratioTyConName, ratioDataConName, realClassName,
    integralClassName, realFracClassName, fractionalClassName,
880
881
    fromRationalName, toIntegerName, toRationalName, fromIntegralName,
    realToFracName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
882
rationalTyConName   = tcQual  gHC_REAL (fsLit "Rational") rationalTyConKey
883
ratioTyConName      = tcQual  gHC_REAL (fsLit "Ratio") ratioTyConKey
Ian Lynagh's avatar
Ian Lynagh committed
884
ratioDataConName    = conName gHC_REAL (fsLit ":%") ratioDataConKey
885
realClassName       = clsQual gHC_REAL (fsLit "Real") realClassKey
Ian Lynagh's avatar
Ian Lynagh committed
886
887
888
integralClassName   = clsQual gHC_REAL (fsLit "Integral") integralClassKey
realFracClassName   = clsQual gHC_REAL (fsLit "RealFrac") realFracClassKey
fractionalClassName = clsQual gHC_REAL (fsLit "Fractional") fractionalClassKey
889
890
891
892
893
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
894
895

-- PrelFloat classes
Ian Lynagh's avatar
Ian Lynagh committed
896
floatingClassName, realFloatClassName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
897
898
floatingClassName  = clsQual  gHC_FLOAT (fsLit "Floating") floatingClassKey
realFloatClassName = clsQual  gHC_FLOAT (fsLit "RealFloat") realFloatClassKey
899
900

-- Class Ix
Ian Lynagh's avatar
Ian Lynagh committed
901
ixClassName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
902
ixClassName = clsQual gHC_ARR (fsLit "Ix") ixClassKey
903

904
-- Class Typeable
Ian Lynagh's avatar
Ian Lynagh committed
905
906
907
typeableClassName, typeable1ClassName, typeable2ClassName,
    typeable3ClassName, typeable4ClassName, typeable5ClassName,
    typeable6ClassName, typeable7ClassName :: Name
908
909
910
911
912
913
914
915
typeableClassName  = clsQual tYPEABLE_INTERNAL (fsLit "Typeable") typeableClassKey
typeable1ClassName = clsQual tYPEABLE_INTERNAL (fsLit "Typeable1") typeable1ClassKey
typeable2ClassName = clsQual tYPEABLE_INTERNAL (fsLit "Typeable2") typeable2ClassKey
typeable3ClassName = clsQual tYPEABLE_INTERNAL (fsLit "Typeable3") typeable3ClassKey
typeable4ClassName = clsQual tYPEABLE_INTERNAL (fsLit "Typeable4") typeable4ClassKey
typeable5ClassName = clsQual tYPEABLE_INTERNAL (fsLit "Typeable5") typeable5ClassKey
typeable6ClassName = clsQual tYPEABLE_INTERNAL (fsLit "Typeable6") typeable6ClassKey
typeable7ClassName = clsQual tYPEABLE_INTERNAL (fsLit "Typeable7") typeable7ClassKey
916

Ian Lynagh's avatar
Ian Lynagh committed
917
typeableClassNames :: [Name]
918
919
920
typeableClassNames =    [ typeableClassName, typeable1ClassName, typeable2ClassName
                        , typeable3ClassName, typeable4ClassName, typeable5ClassName
                        , typeable6ClassName, typeable7ClassName ]
921
922

-- Class Data
Ian Lynagh's avatar
Ian Lynagh committed
923
dataClassName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
924
dataClassName = clsQual gENERICS (fsLit "Data") dataClassKey
925
926

-- Error module
Ian Lynagh's avatar
Ian Lynagh committed
927
assertErrorName    :: Name
928
assertErrorName   = varQual gHC_IO_Exception (fsLit "assertError") assertErrorIdKey
929

930
-- Enum module (Enum, Bounded)
Ian Lynagh's avatar
Ian Lynagh committed
931
932
enumClassName, enumFromName, enumFromToName, enumFromThenName,
    enumFromThenToName, boundedClassName :: Name
933
934
935
enumClassName      = clsQual gHC_ENUM (fsLit "Enum") enumClassKey
enumFromName       = methName gHC_ENUM (fsLit "enumFrom") enumFromClassOpKey
enumFromToName     = methName gHC_ENUM (fsLit "enumFromTo") enumFromToClassOpKey
Ian Lynagh's avatar
Ian Lynagh committed
936
937
938
enumFromThenName   = methName gHC_ENUM (fsLit "enumFromThen") enumFromThenClassOpKey
enumFromThenToName = methName gHC_ENUM (fsLit "enumFromThenTo") enumFromThenToClassOpKey
boundedClassName   = clsQual gHC_ENUM (fsLit "Bounded") boundedClassKey
939
940

-- List functions
Ian Lynagh's avatar
Ian Lynagh committed
941
concatName, filterName, zipName :: Name
942
943
944
concatName        = varQual gHC_LIST (fsLit "concat") concatIdKey
filterName        = varQual gHC_LIST (fsLit "filter") filterIdKey
zipName           = varQual gHC_LIST (fsLit "zip") zipIdKey
945

946
-- Class Show
Ian Lynagh's avatar
Ian Lynagh committed
947
showClassName :: Name
948
showClassName     = clsQual gHC_SHOW (fsLit "Show")       showClassKey
949
950

-- Class Read
Ian Lynagh's avatar
Ian Lynagh committed
951
readClassName :: Name
952
readClassName      = clsQual gHC_READ (fsLit "Read") readClassKey
953

954
955
-- Classes Generic and Generic1, Datatype, Constructor and Selector
genClassName, gen1ClassName, datatypeClassName, constructorClassName,
956
  selectorClassName :: Name
957
958
genClassName  = clsQual gHC_GENERICS (fsLit "Generic")  genClassKey
gen1ClassName = clsQual gHC_GENERICS (fsLit "Generic1") gen1ClassKey
959
960
961
962
963

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
964
-- parallel array types and functions
Ian Lynagh's avatar
Ian Lynagh committed
965
966
enumFromToPName, enumFromThenToPName, nullPName, lengthPName,
    singletonPName, replicatePName, mapPName, filterPName,
967
    zipPName, crossMapPName, indexPName, toPName,
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
    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
983

984
-- IO things
Ian Lynagh's avatar
Ian Lynagh committed
985
986
ioTyConName, ioDataConName, thenIOName, bindIOName, returnIOName,
    failIOName :: Name
987
ioTyConName       = tcQual  gHC_TYPES (fsLit "IO") ioTyConKey
988
ioDataConName     = conName gHC_TYPES (fsLit "IO") ioDataConKey
989
990
991
992
thenIOName        = varQual gHC_BASE (fsLit "thenIO") thenIOIdKey
bindIOName        = varQual gHC_BASE (fsLit "bindIO") bindIOIdKey
returnIOName      = varQual gHC_BASE (fsLit "returnIO") returnIOIdKey
failIOName        = varQual gHC_IO (fsLit "failIO") failIOIdKey
993

994
-- IO things
Ian Lynagh's avatar
Ian Lynagh committed
995
printName :: Name
996
printName         = varQual sYSTEM_IO (fsLit "print") printIdKey
997

998
-- Int, Word, and Addr things
Ian Lynagh's avatar
Ian Lynagh committed
999
int8TyConName, int16TyConName, int32TyConName, int64TyConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
1000
1001
1002
1003
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
1004

1005
-- Word module
Ian Lynagh's avatar
Ian Lynagh committed
1006
1007
word8TyConName, word16TyConName, word32TyConName, word64TyConName,
    wordTyConName, wordDataConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
1008
1009
1010
1011
1012
1013
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
1014

1015
-- PrelPtr module
Ian Lynagh's avatar
Ian Lynagh committed
1016
ptrTyConName, funPtrTyConName :: Name
1017
1018
ptrTyConName      = tcQual   gHC_PTR (fsLit "Ptr") ptrTyConKey
funPtrTyConName   = tcQual   gHC_PTR (fsLit "FunPtr") funPtrTyConKey
1019

chak's avatar
chak committed
1020
-- Foreign objects and weak pointers
Ian Lynagh's avatar
Ian Lynagh committed
1021
stablePtrTyConName, newStablePtrName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
1022
1023
stablePtrTyConName    = tcQual   gHC_STABLE (fsLit "StablePtr") stablePtrTyConKey
newStablePtrName      = varQual  gHC_STABLE (fsLit "newStablePtr") newStablePtrIdKey
1024
1025

-- PrelST module
Ian Lynagh's avatar
Ian Lynagh committed
1026
runSTRepName :: Name
1027
runSTRepName       = varQual gHC_ST  (fsLit "runSTRep") runSTRepIdKey
1028

1029
-- Recursive-do notation
Ian Lynagh's avatar
Ian Lynagh committed
1030
monadFixClassName, mfixName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
1031
monadFixClassName  = clsQual mONAD_FIX (fsLit "MonadFix") monadFixClassKey
1032
mfixName           = methName mONAD_FIX (fsLit "mfix") mfixIdKey
sof's avatar
sof committed
1033

1034
-- Arrow notation
Ian Lynagh's avatar
Ian Lynagh committed
1035
arrAName, composeAName, firstAName, appAName, choiceAName, loopAName :: Name
1036
1037
1038
1039
1040
1041
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
1042

1043
1044
1045
1046
1047
1048
1049
1050
-- Monad comprehensions
guardMName, liftMName, groupMName, mzipName :: Name
guardMName         = varQual mONAD (fsLit "guard") guardMIdKey
liftMName          = varQual mONAD (fsLit "liftM") liftMIdKey
groupMName         = varQual mONAD_GROUP (fsLit "mgroupWith") groupMIdKey
mzipName           = varQual mONAD_ZIP (fsLit "mzip") mzipIdKey


1051
1052
1053
1054
-- Annotation type checking
toAnnotationWrapperName :: Name
toAnnotationWrapperName = varQual gHC_DESUGAR (fsLit "toAnnotationWrapper") toAnnotationWrapperIdKey

1055
-- Other classes, needed for type defaulting
Ian Lynagh's avatar
Ian Lynagh committed
1056
1057
monadPlusClassName, randomClassName, randomGenClassName,
    isStringClassName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
1058
1059
1060
1061
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
1062

sof's avatar
sof committed
1063
-- dotnet interop
Ian Lynagh's avatar
Ian Lynagh committed
1064
objectTyConName :: Name
1065
1066
1067
objectTyConName     = tcQual   dOTNET (fsLit "Object") objectTyConKey
        -- objectTyConName was "wTcQual", but that's gone now, and
        -- I can't see why it was wired in anyway...
Ian Lynagh's avatar