PrelNames.lhs 76.8 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
160
161
162
163
164
165
 ++ [   -- Type constructors (synonyms especially)
        ioTyConName, ioDataConName,
        runMainIOName,
        rationalTyConName,
        stringTyConName,
        ratioDataConName,
        ratioTyConName,
166
        integerTyConName,
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190

        --  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
191
192
193
194
195
196
        negateName, minusName, geName, eqName,

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

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

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

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

210
211
        -- MonadRec stuff
        mfixName,
212

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

217
218
        -- Ix stuff
        ixClassName,
219

220
221
        -- Show stuff
        showClassName,
222

223
224
        -- Read stuff
        readClassName,
225

226
227
        -- Stable pointers
        newStablePtrName,
228

229
    -- GHC Extensions
230
        groupWithName,
231

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

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

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

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

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

254
        -- Integer
255
        integerTyConName, mkIntegerName,
256
        integerToWord64Name, integerToInt64Name,
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
        quotIntegerName, remIntegerName,
264
        floatFromIntegerName, doubleFromIntegerName,
265
        encodeFloatIntegerName, encodeDoubleIntegerName,
266
267
268
269
        gcdIntegerName, lcmIntegerName,
        andIntegerName, orIntegerName, xorIntegerName, complementIntegerName,
        shiftLIntegerName, shiftRIntegerName,

270
271
        -- MonadFix
        monadFixClassName, mfixName,
272

273
274
        -- Other classes
        randomClassName, randomGenClassName, monadPlusClassName,
275

276
        -- Annotation type checking
277
        toAnnotationWrapperName
278

279
280
281
        -- The Ordering type
        , orderingTyConName, ltDataConName, eqDataConName, gtDataConName

282
283
        -- The Either type
        , eitherTyConName, leftDataConName, rightDataConName
284

285
286
        -- Plugins
        , pluginTyConName
287
288
289
290
291
292
293
294
295

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

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

296
297
298
299
        -- Monad comprehensions
        , guardMName
        , liftMName
        , mzipName
300
    ]
301

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


314
%************************************************************************
315
%*                                                                      *
316
\subsection{Module names}
317
%*                                                                      *
318
319
%************************************************************************

320
321

--MetaHaskell Extension Add a new module here
322
\begin{code}
Ian Lynagh's avatar
Ian Lynagh committed
323
pRELUDE :: Module
324
pRELUDE         = mkBaseModule_ pRELUDE_NAME
Ian Lynagh's avatar
Ian Lynagh committed
325

Ian Lynagh's avatar
Ian Lynagh committed
326
gHC_PRIM, gHC_TYPES, gHC_GENERICS,
Ian Lynagh's avatar
Ian Lynagh committed
327
    gHC_MAGIC,
328
    gHC_CLASSES, gHC_BASE, gHC_ENUM, gHC_CSTRING,
329
    gHC_SHOW, gHC_READ, gHC_NUM, gHC_INTEGER_TYPE, gHC_LIST,
330
    gHC_TUPLE, dATA_TUPLE, dATA_EITHER, dATA_STRING, dATA_FOLDABLE, dATA_TRAVERSABLE,
dterei's avatar
dterei committed
331
332
    gHC_CONC, gHC_IO, gHC_IO_Exception,
    gHC_ST, gHC_ARR, gHC_STABLE, gHC_PTR, gHC_ERR, gHC_REAL,
333
    gHC_FLOAT, gHC_TOP_HANDLER, sYSTEM_IO, dYNAMIC, tYPEABLE, tYPEABLE_INTERNAL, gENERICS,
334
    dOTNET, rEAD_PREC, lEX, gHC_INT, gHC_WORD, mONAD, mONAD_FIX, mONAD_ZIP,
335
336
    aRROW, cONTROL_APPLICATIVE, gHC_DESUGAR, rANDOM, gHC_EXTS,
    cONTROL_EXCEPTION_BASE :: Module
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
337

338
gHC_PRIM        = mkPrimModule (fsLit "GHC.Prim")   -- Primitive types and values
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
339
gHC_TYPES       = mkPrimModule (fsLit "GHC.Types")
340
341
342
343
344
345
346
347
348
349
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
350
gHC_INTEGER_TYPE= mkIntegerModule (fsLit "GHC.Integer.Type")
351
352
353
gHC_LIST        = mkBaseModule (fsLit "GHC.List")
gHC_TUPLE       = mkPrimModule (fsLit "GHC.Tuple")
dATA_TUPLE      = mkBaseModule (fsLit "Data.Tuple")
354
355
356
dATA_EITHER     = mkBaseModule (fsLit "Data.Either")
dATA_STRING     = mkBaseModule (fsLit "Data.String")
dATA_FOLDABLE   = mkBaseModule (fsLit "Data.Foldable")
357
dATA_TRAVERSABLE= mkBaseModule (fsLit "Data.Traversable")
358
359
gHC_CONC        = mkBaseModule (fsLit "GHC.Conc")
gHC_IO          = mkBaseModule (fsLit "GHC.IO")
360
gHC_IO_Exception = mkBaseModule (fsLit "GHC.IO.Exception")
361
362
363
364
365
366
367
368
369
370
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")
371
372
tYPEABLE        = mkBaseModule (fsLit "Data.Typeable")
tYPEABLE_INTERNAL = mkBaseModule (fsLit "Data.Typeable.Internal")
373
gENERICS        = mkBaseModule (fsLit "Data.Data")
374
375
376
377
378
379
380
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")
381
mONAD_ZIP       = mkBaseModule (fsLit "Control.Monad.Zip")
382
aRROW           = mkBaseModule (fsLit "Control.Arrow")
383
cONTROL_APPLICATIVE = mkBaseModule (fsLit "Control.Applicative")
Ian Lynagh's avatar
Ian Lynagh committed
384
gHC_DESUGAR = mkBaseModule (fsLit "GHC.Desugar")
385
386
rANDOM          = mkBaseModule (fsLit "System.Random")
gHC_EXTS        = mkBaseModule (fsLit "GHC.Exts")
387
cONTROL_EXCEPTION_BASE = mkBaseModule (fsLit "Control.Exception.Base")
Simon Marlow's avatar
Simon Marlow committed
388

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

Ian Lynagh's avatar
Ian Lynagh committed
392
mAIN, rOOT_MAIN :: Module
393
394
mAIN            = mkMainModule_ mAIN_NAME
rOOT_MAIN       = mkMainModule (fsLit ":Main") -- Root module for initialisation
Simon Marlow's avatar
Simon Marlow committed
395

396
397
398
399
        -- 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.
400
iNTERACTIVE :: Module
Ian Lynagh's avatar
Ian Lynagh committed
401
iNTERACTIVE    = mkMainModule (fsLit ":Interactive")
Simon Marlow's avatar
Simon Marlow committed
402

Ian Lynagh's avatar
Ian Lynagh committed
403
pRELUDE_NAME, mAIN_NAME :: ModuleName
Ian Lynagh's avatar
Ian Lynagh committed
404
405
pRELUDE_NAME   = mkModuleNameFS (fsLit "Prelude")
mAIN_NAME      = mkModuleNameFS (fsLit "Main")
Simon Marlow's avatar
Simon Marlow committed
406

407
408
409
410
dATA_ARRAY_PARALLEL_NAME, dATA_ARRAY_PARALLEL_PRIM_NAME :: ModuleName
dATA_ARRAY_PARALLEL_NAME      = mkModuleNameFS (fsLit "Data.Array.Parallel")
dATA_ARRAY_PARALLEL_PRIM_NAME = mkModuleNameFS (fsLit "Data.Array.Parallel.Prim")

Ian Lynagh's avatar
Ian Lynagh committed
411
412
413
414
415
416
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
417
418
419
420
421
422
mkBaseModule :: FastString -> Module
mkBaseModule m = mkModule basePackageId (mkModuleNameFS m)

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

423
424
425
426
427
428
mkThisGhcModule :: FastString -> Module
mkThisGhcModule m = mkModule thisGhcPackageId (mkModuleNameFS m)

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

Simon Marlow's avatar
Simon Marlow committed
429
430
mkMainModule :: FastString -> Module
mkMainModule m = mkModule mainPackageId (mkModuleNameFS m)
431

Simon Marlow's avatar
Simon Marlow committed
432
433
mkMainModule_ :: ModuleName -> Module
mkMainModule_ m = mkModule mainPackageId m
434
435
436
\end{code}

%************************************************************************
437
%*                                                                      *
438
\subsection{Constructing the names of tuples
439
%*                                                                      *
440
441
442
%************************************************************************

\begin{code}
batterseapower's avatar
batterseapower committed
443
444
mkTupleModule :: TupleSort -> Arity -> Module
mkTupleModule BoxedTuple   _ = gHC_TUPLE
445
mkTupleModule ConstraintTuple    _ = gHC_TUPLE
batterseapower's avatar
batterseapower committed
446
mkTupleModule UnboxedTuple _ = gHC_PRIM
447
448
449
\end{code}


450
%************************************************************************
451
452
453
%*                                                                      *
                        RdrNames
%*                                                                      *
454
455
456
%************************************************************************

\begin{code}
Ian Lynagh's avatar
Ian Lynagh committed
457
main_RDR_Unqual    :: RdrName
458
459
460
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
461

462
forall_tv_RDR, dot_tv_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
463
464
forall_tv_RDR = mkUnqual tvName (fsLit "forall")
dot_tv_RDR    = mkUnqual tvName (fsLit ".")
465

Ian Lynagh's avatar
Ian Lynagh committed
466
467
eq_RDR, ge_RDR, ne_RDR, le_RDR, lt_RDR, gt_RDR, compare_RDR,
    ltTag_RDR, eqTag_RDR, gtTag_RDR :: RdrName
468
469
470
471
472
473
474
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
475
476
477
ltTag_RDR               = dataQual_RDR gHC_TYPES (fsLit "LT")
eqTag_RDR               = dataQual_RDR gHC_TYPES (fsLit "EQ")
gtTag_RDR               = dataQual_RDR gHC_TYPES (fsLit "GT")
478

Ian Lynagh's avatar
Ian Lynagh committed
479
480
eqClass_RDR, numClass_RDR, ordClass_RDR, enumClass_RDR, monadClass_RDR
    :: RdrName
481
482
483
484
485
eqClass_RDR             = nameRdrName eqClassName
numClass_RDR            = nameRdrName numClassName
ordClass_RDR            = nameRdrName ordClassName
enumClass_RDR           = nameRdrName enumClassName
monadClass_RDR          = nameRdrName monadClassName
486

Ian Lynagh's avatar
Ian Lynagh committed
487
map_RDR, append_RDR :: RdrName
488
489
map_RDR                 = varQual_RDR gHC_BASE (fsLit "map")
append_RDR              = varQual_RDR gHC_BASE (fsLit "++")
490

Ian Lynagh's avatar
Ian Lynagh committed
491
foldr_RDR, build_RDR, returnM_RDR, bindM_RDR, failM_RDR :: RdrName
492
493
494
495
496
foldr_RDR               = nameRdrName foldrName
build_RDR               = nameRdrName buildName
returnM_RDR             = nameRdrName returnMName
bindM_RDR               = nameRdrName bindMName
failM_RDR               = nameRdrName failMName
497

Ian Lynagh's avatar
Ian Lynagh committed
498
left_RDR, right_RDR :: RdrName
499
500
left_RDR                = nameRdrName leftDataConName
right_RDR               = nameRdrName rightDataConName
501

Ian Lynagh's avatar
Ian Lynagh committed
502
fromEnum_RDR, toEnum_RDR :: RdrName
503
504
fromEnum_RDR            = varQual_RDR gHC_ENUM (fsLit "fromEnum")
toEnum_RDR              = varQual_RDR gHC_ENUM (fsLit "toEnum")
505

Ian Lynagh's avatar
Ian Lynagh committed
506
enumFrom_RDR, enumFromTo_RDR, enumFromThen_RDR, enumFromThenTo_RDR :: RdrName
507
508
509
510
enumFrom_RDR            = nameRdrName enumFromName
enumFromTo_RDR          = nameRdrName enumFromToName
enumFromThen_RDR        = nameRdrName enumFromThenName
enumFromThenTo_RDR      = nameRdrName enumFromThenToName
511

Ian Lynagh's avatar
Ian Lynagh committed
512
ratioDataCon_RDR, plusInteger_RDR, timesInteger_RDR :: RdrName
513
514
515
ratioDataCon_RDR        = nameRdrName ratioDataConName
plusInteger_RDR         = nameRdrName plusIntegerName
timesInteger_RDR        = nameRdrName timesIntegerName
516

Ian Lynagh's avatar
Ian Lynagh committed
517
ioDataCon_RDR :: RdrName
518
ioDataCon_RDR           = nameRdrName ioDataConName
519

Ian Lynagh's avatar
Ian Lynagh committed
520
521
eqString_RDR, unpackCString_RDR, unpackCStringFoldr_RDR,
    unpackCStringUtf8_RDR :: RdrName
522
523
524
525
eqString_RDR            = nameRdrName eqStringName
unpackCString_RDR       = nameRdrName unpackCStringName
unpackCStringFoldr_RDR  = nameRdrName unpackCStringFoldrName
unpackCStringUtf8_RDR   = nameRdrName unpackCStringUtf8Name
526

Ian Lynagh's avatar
Ian Lynagh committed
527
newStablePtr_RDR, wordDataCon_RDR :: RdrName
528
529
newStablePtr_RDR        = nameRdrName newStablePtrName
wordDataCon_RDR         = dataQual_RDR gHC_WORD (fsLit "W#")
530

Ian Lynagh's avatar
Ian Lynagh committed
531
bindIO_RDR, returnIO_RDR :: RdrName
532
533
bindIO_RDR              = nameRdrName bindIOName
returnIO_RDR            = nameRdrName returnIOName
534

Ian Lynagh's avatar
Ian Lynagh committed
535
fromInteger_RDR, fromRational_RDR, minus_RDR, times_RDR, plus_RDR :: RdrName
536
537
538
539
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
540
plus_RDR                = varQual_RDR gHC_NUM (fsLit "+")
Simon Marlow's avatar
Simon Marlow committed
541

Ian Lynagh's avatar
Ian Lynagh committed
542
fromString_RDR :: RdrName
543
fromString_RDR          = nameRdrName fromStringName
544

Ian Lynagh's avatar
Ian Lynagh committed
545
compose_RDR :: RdrName
546
compose_RDR             = varQual_RDR gHC_BASE (fsLit ".")
Simon Marlow's avatar
Simon Marlow committed
547

Ian Lynagh's avatar
Ian Lynagh committed
548
not_RDR, getTag_RDR, succ_RDR, pred_RDR, minBound_RDR, maxBound_RDR,
549
    and_RDR, range_RDR, inRange_RDR, index_RDR,
Ian Lynagh's avatar
Ian Lynagh committed
550
    unsafeIndex_RDR, unsafeRangeSize_RDR :: RdrName
551
552
553
554
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
555
556
557
558
559
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")
560
561
562
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
563

Ian Lynagh's avatar
Ian Lynagh committed
564
565
readList_RDR, readListDefault_RDR, readListPrec_RDR, readListPrecDefault_RDR,
    readPrec_RDR, parens_RDR, choose_RDR, lexP_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
566
567
568
569
570
571
572
573
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")
574

Ian Lynagh's avatar
Ian Lynagh committed
575
punc_RDR, ident_RDR, symbol_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
576
577
578
punc_RDR                = dataQual_RDR lEX (fsLit "Punc")
ident_RDR               = dataQual_RDR lEX (fsLit "Ident")
symbol_RDR              = dataQual_RDR lEX (fsLit "Symbol")
579

Ian Lynagh's avatar
Ian Lynagh committed
580
step_RDR, alt_RDR, reset_RDR, prec_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
581
step_RDR                = varQual_RDR  rEAD_PREC (fsLit "step")
582
alt_RDR                 = varQual_RDR  rEAD_PREC (fsLit "+++")
Ian Lynagh's avatar
Ian Lynagh committed
583
584
reset_RDR               = varQual_RDR  rEAD_PREC (fsLit "reset")
prec_RDR                = varQual_RDR  rEAD_PREC (fsLit "prec")
585

Ian Lynagh's avatar
Ian Lynagh committed
586
587
showList_RDR, showList___RDR, showsPrec_RDR, showString_RDR,
    showSpace_RDR, showParen_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
588
589
showList_RDR            = varQual_RDR gHC_SHOW (fsLit "showList")
showList___RDR          = varQual_RDR gHC_SHOW (fsLit "showList__")
590
showsPrec_RDR           = varQual_RDR gHC_SHOW (fsLit "showsPrec")
Ian Lynagh's avatar
Ian Lynagh committed
591
showString_RDR          = varQual_RDR gHC_SHOW (fsLit "showString")
592
593
showSpace_RDR           = varQual_RDR gHC_SHOW (fsLit "showSpace")
showParen_RDR           = varQual_RDR gHC_SHOW (fsLit "showParen")
594

595
typeOf_RDR, mkTyCon_RDR, mkTyConApp_RDR :: RdrName
596
typeOf_RDR     = varQual_RDR tYPEABLE_INTERNAL (fsLit "typeOf")
597
mkTyCon_RDR    = varQual_RDR tYPEABLE_INTERNAL (fsLit "mkTyCon")
598
mkTyConApp_RDR = varQual_RDR tYPEABLE_INTERNAL (fsLit "mkTyConApp")
599

Ian Lynagh's avatar
Ian Lynagh committed
600
undefined_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
601
undefined_RDR = varQual_RDR gHC_ERR (fsLit "undefined")
602

603
604
605
606
607
608
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,
609
610
  prodDataCon_RDR, comp1DataCon_RDR, from_RDR, from1_RDR,
  to_RDR, to1_RDR, datatypeName_RDR, moduleName_RDR, conName_RDR,
611
  conFixity_RDR, conIsRecord_RDR,
612
  noArityDataCon_RDR, arityDataCon_RDR, selName_RDR,
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
  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")

628
from_RDR  = varQual_RDR gHC_GENERICS (fsLit "from")
629
from1_RDR = varQual_RDR gHC_GENERICS (fsLit "from1")
630
to_RDR    = varQual_RDR gHC_GENERICS (fsLit "to")
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
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")


649
fmap_RDR, pure_RDR, ap_RDR, foldable_foldr_RDR, traverse_RDR :: RdrName
650
651
652
653
654
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")
655

656
----------------------
Ian Lynagh's avatar
Ian Lynagh committed
657
658
varQual_RDR, tcQual_RDR, clsQual_RDR, dataQual_RDR
    :: Module -> FastString -> RdrName
659
660
661
662
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)
663
\end{code}
664

665
%************************************************************************
666
%*                                                                      *
667
\subsection{Known-key names}
668
%*                                                                      *
669
670
%************************************************************************

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

675
--MetaHaskell Extension  add the constrs and the lower case case
676
-- guys as well (perhaps) e.g. see  trueDataConName     below
677
678


679
\begin{code}
680
681
682
wildCardName :: Name
wildCardName = mkSystemVarName wildCardKey (fsLit "wild")

Ian Lynagh's avatar
Ian Lynagh committed
683
runMainIOName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
684
runMainIOName = varQual gHC_TOP_HANDLER (fsLit "runMainIO") runMainKey
685

686
orderingTyConName, ltDataConName, eqDataConName, gtDataConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
687
688
689
690
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
691

Ian Lynagh's avatar
Ian Lynagh committed
692
eitherTyConName, leftDataConName, rightDataConName :: Name
693
eitherTyConName   = tcQual  dATA_EITHER (fsLit "Either") eitherTyConKey
Ian Lynagh's avatar
Ian Lynagh committed
694
695
leftDataConName   = conName dATA_EITHER (fsLit "Left")   leftDataConKey
rightDataConName  = conName dATA_EITHER (fsLit "Right")  rightDataConKey
696

697
698
699
-- Generics (types)
v1TyConName, u1TyConName, par1TyConName, rec1TyConName,
  k1TyConName, m1TyConName, sumTyConName, prodTyConName,
700
  compTyConName, rTyConName, pTyConName, dTyConName,
701
702
  cTyConName, sTyConName, rec0TyConName, par0TyConName,
  d1TyConName, c1TyConName, s1TyConName, noSelTyConName,
703
  repTyConName, rep1TyConName :: Name
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728

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

729
repTyConName  = tcQual gHC_GENERICS (fsLit "Rep")  repTyConKey
730
731
rep1TyConName = tcQual gHC_GENERICS (fsLit "Rep1") rep1TyConKey

732
-- Base strings Strings
Ian Lynagh's avatar
Ian Lynagh committed
733
unpackCStringName, unpackCStringFoldrName,
Ian Lynagh's avatar
Ian Lynagh committed
734
    unpackCStringUtf8Name, eqStringName, stringTyConName :: Name
735
736
737
unpackCStringName       = varQual gHC_CSTRING (fsLit "unpackCString#") unpackCStringIdKey
unpackCStringFoldrName  = varQual gHC_CSTRING (fsLit "unpackFoldrCString#") unpackCStringFoldrIdKey
unpackCStringUtf8Name   = varQual gHC_CSTRING (fsLit "unpackCStringUtf8#") unpackCStringUtf8IdKey
738
eqStringName            = varQual gHC_BASE (fsLit "eqString")  eqStringIdKey
Ian Lynagh's avatar
Ian Lynagh committed
739
stringTyConName         = tcQual  gHC_BASE (fsLit "String") stringTyConKey
740

741
-- The 'inline' function
Ian Lynagh's avatar
Ian Lynagh committed
742
inlineIdName :: Name
743
inlineIdName            = varQual gHC_MAGIC (fsLit "inline") inlineIdKey
744

745
746
747
748
-- The 'undefined' function. Used by supercompilation.
undefinedName :: Name
undefinedName = varQual gHC_ERR (fsLit "undefined") undefinedKey

749
-- Base classes (Eq, Ord, Functor)
750
fmapName, eqClassName, eqName, ordClassName, geName, functorClassName :: Name
751
752
753
754
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
755
functorClassName  = clsQual  gHC_BASE (fsLit "Functor") functorClassKey
756
fmapName          = methName gHC_BASE (fsLit "fmap")    fmapClassOpKey
757
758

-- Class Monad
Ian Lynagh's avatar
Ian Lynagh committed
759
monadClassName, thenMName, bindMName, returnMName, failMName :: Name
760
761
762
763
764
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
765

766
767
768
769
770
771
-- 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

772
-- Functions for GHC extensions
Ian Lynagh's avatar
Ian Lynagh committed
773
groupWithName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
774
groupWithName = varQual gHC_EXTS (fsLit "groupWith") groupWithIdKey
775

776
-- Random PrelBase functions
Ian Lynagh's avatar
Ian Lynagh committed
777
fromStringName, otherwiseIdName, foldrName, buildName, augmentName,
778
    mapName, appendName, assertName,
Ian Lynagh's avatar
Ian Lynagh committed
779
    breakpointName, breakpointCondName, breakpointAutoName,
780
    dollarName, opaqueTyConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
781
782
fromStringName = methName dATA_STRING (fsLit "fromString") fromStringClassOpKey
otherwiseIdName   = varQual gHC_BASE (fsLit "otherwise")  otherwiseIdKey
783
784
785
foldrName         = varQual gHC_BASE (fsLit "foldr")      foldrIdKey
buildName         = varQual gHC_BASE (fsLit "build")      buildIdKey
augmentName       = varQual gHC_BASE (fsLit "augment")    augmentIdKey
786
mapName           = varQual gHC_BASE (fsLit "map")        mapIdKey
787
788
appendName        = varQual gHC_BASE (fsLit "++")         appendIdKey
dollarName        = varQual gHC_BASE (fsLit "$")          dollarIdKey
Ian Lynagh's avatar
Ian Lynagh committed
789
790
791
792
793
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
794

Ian Lynagh's avatar
Ian Lynagh committed
795
breakpointJumpName :: Name
796
797
798
breakpointJumpName
    = mkInternalName
        breakpointJumpIdKey
Ian Lynagh's avatar
Ian Lynagh committed
799
        (mkOccNameFS varName (fsLit "breakpointJump"))
800
        noSrcSpan
Ian Lynagh's avatar
Ian Lynagh committed
801
breakpointCondJumpName :: Name
David Himmelstrup's avatar
David Himmelstrup committed
802
803
804
breakpointCondJumpName
    = mkInternalName
        breakpointCondJumpIdKey
Ian Lynagh's avatar
Ian Lynagh committed
805
        (mkOccNameFS varName (fsLit "breakpointCondJump"))
806
        noSrcSpan
Ian Lynagh's avatar
Ian Lynagh committed
807
breakpointAutoJumpName :: Name
mnislaih's avatar
mnislaih committed
808
809
810
breakpointAutoJumpName
    = mkInternalName
        breakpointAutoJumpIdKey
Ian Lynagh's avatar
Ian Lynagh committed
811
        (mkOccNameFS varName (fsLit "breakpointAutoJump"))
812
        noSrcSpan
813

814
-- PrelTup
Ian Lynagh's avatar
Ian Lynagh committed
815
fstName, sndName :: Name
816
817
fstName           = varQual dATA_TUPLE (fsLit "fst") fstIdKey
sndName           = varQual dATA_TUPLE (fsLit "snd") sndIdKey
818

819
-- Module GHC.Num
820
numClassName, fromIntegerName, minusName, negateName :: Name
821
numClassName      = clsQual  gHC_NUM (fsLit "Num") numClassKey
Ian Lynagh's avatar
Ian Lynagh committed
822
fromIntegerName   = methName gHC_NUM (fsLit "fromInteger") fromIntegerClassOpKey
823
824
minusName         = methName gHC_NUM (fsLit "-") minusClassOpKey
negateName        = methName gHC_NUM (fsLit "negate") negateClassOpKey
825

826
integerTyConName, mkIntegerName,
827
    integerToWord64Name, integerToInt64Name,
828
    plusIntegerName, timesIntegerName, smallIntegerName,
829
830
831
832
    integerToWordName, integerToIntName, minusIntegerName,
    negateIntegerName, eqIntegerName, neqIntegerName,
    absIntegerName, signumIntegerName,
    leIntegerName, gtIntegerName, ltIntegerName, geIntegerName,
Ian Lynagh's avatar
Ian Lynagh committed
833
    compareIntegerName, quotRemIntegerName, divModIntegerName,
834
    quotIntegerName, remIntegerName,
835
    floatFromIntegerName, doubleFromIntegerName,
836
    encodeFloatIntegerName, encodeDoubleIntegerName,
837
838
839
    gcdIntegerName, lcmIntegerName,
    andIntegerName, orIntegerName, xorIntegerName, complementIntegerName,
    shiftLIntegerName, shiftRIntegerName :: Name
840
841
integerTyConName      = tcQual  gHC_INTEGER_TYPE (fsLit "Integer")           integerTyConKey
mkIntegerName         = varQual gHC_INTEGER_TYPE (fsLit "mkInteger")         mkIntegerIdKey
842
843
integerToWord64Name   = varQual gHC_INTEGER_TYPE (fsLit "integerToWord64")   integerToWord64IdKey
integerToInt64Name    = varQual gHC_INTEGER_TYPE (fsLit "integerToInt64")    integerToInt64IdKey
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
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
860
861
quotRemIntegerName    = varQual gHC_INTEGER_TYPE (fsLit "quotRemInteger")    quotRemIntegerIdKey
divModIntegerName     = varQual gHC_INTEGER_TYPE (fsLit "divModInteger")     divModIntegerIdKey
862
863
quotIntegerName       = varQual gHC_INTEGER_TYPE (fsLit "quotInteger")       quotIntegerIdKey
remIntegerName        = varQual gHC_INTEGER_TYPE (fsLit "remInteger")        remIntegerIdKey
864
865
866
867
floatFromIntegerName  = varQual gHC_INTEGER_TYPE (fsLit "floatFromInteger")      floatFromIntegerIdKey
doubleFromIntegerName = varQual gHC_INTEGER_TYPE (fsLit "doubleFromInteger")     doubleFromIntegerIdKey
encodeFloatIntegerName  = varQual gHC_INTEGER_TYPE (fsLit "encodeFloatInteger")  encodeFloatIntegerIdKey
encodeDoubleIntegerName = varQual gHC_INTEGER_TYPE (fsLit "encodeDoubleInteger") encodeDoubleIntegerIdKey
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

964
-- IO things
Ian Lynagh's avatar
Ian Lynagh committed
965
966
ioTyConName, ioDataConName, thenIOName, bindIOName, returnIOName,
    failIOName :: Name
967
ioTyConName       = tcQual  gHC_TYPES (fsLit "IO") ioTyConKey
968
ioDataConName     = conName gHC_TYPES (fsLit "IO") ioDataConKey
969
970
971
972
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
973

974
-- IO things
Ian Lynagh's avatar
Ian Lynagh committed
975
printName :: Name
976
printName         = varQual sYSTEM_IO (fsLit "print") printIdKey
977

978
-- Int, Word, and Addr things
Ian Lynagh's avatar
Ian Lynagh committed
979
int8TyConName, int16TyConName, int32TyConName, int64TyConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
980
981
982
983
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
984

985
-- Word module
Ian Lynagh's avatar
Ian Lynagh committed
986
987
word8TyConName, word16TyConName, word32TyConName, word64TyConName,
    wordTyConName, wordDataConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
988
989
990
991
992
993
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
994

995
-- PrelPtr module
Ian Lynagh's avatar
Ian Lynagh committed
996
ptrTyConName, funPtrTyConName :: Name
997
998
ptrTyConName      = tcQual   gHC_PTR (fsLit "Ptr") ptrTyConKey
funPtrTyConName   = tcQual   gHC_PTR (fsLit "FunPtr") funPtrTyConKey
999

chak's avatar
chak committed
1000
-- Foreign objects and weak pointers
Ian Lynagh's avatar
Ian Lynagh committed
1001
stablePtrTyConName, newStablePtrName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
1002
1003
stablePtrTyConName    = tcQual   gHC_STABLE (fsLit "StablePtr") stablePtrTyConKey
newStablePtrName      = varQual  gHC_STABLE (fsLit "newStablePtr") newStablePtrIdKey
1004
1005

-- PrelST module
Ian Lynagh's avatar
Ian Lynagh committed
1006
runSTRepName :: Name
1007
runSTRepName       = varQual gHC_ST  (fsLit "runSTRep") runSTRepIdKey
1008

1009
-- Recursive-do notation
Ian Lynagh's avatar
Ian Lynagh committed
1010
monadFixClassName, mfixName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
1011
monadFixClassName  = clsQual mONAD_FIX (fsLit "MonadFix") monadFixClassKey
1012
mfixName           = methName mONAD_FIX (fsLit "mfix") mfixIdKey
sof's avatar
sof committed
1013

1014
-- Arrow notation
Ian Lynagh's avatar
Ian Lynagh committed
1015
arrAName, composeAName, firstAName, appAName, choiceAName, loopAName :: Name
1016
1017
1018
1019
1020
1021
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
1022

1023
-- Monad comprehensions
1024
guardMName, liftMName, mzipName :: Name
1025
1026
1027
1028
1029
guardMName         = varQual mONAD (fsLit "guard") guardMIdKey
liftMName          = varQual mONAD (fsLit "liftM") liftMIdKey
mzipName           = varQual mONAD_ZIP (fsLit "mzip") mzipIdKey


1030
1031
1032
1033
-- Annotation type checking
toAnnotationWrapperName :: Name
toAnnotationWrapperName = varQual gHC_DESUGAR (fsLit "toAnnotationWrapper") toAnnotationWrapperIdKey

1034
-- Other classes, needed for type defaulting
Ian Lynagh's avatar
Ian Lynagh committed
1035
1036
monadPlusClassName, randomClassName, randomGenClassName,
    isStringClassName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
1037
1038
1039
1040
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
1041

sof's avatar
sof committed
1042
-- dotnet interop
Ian Lynagh's avatar
Ian Lynagh committed
1043
objectTyConName :: Name