PrelNames.hs 108 KB
Newer Older
Austin Seipp's avatar
Austin Seipp committed
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
Peter Trommler's avatar
Peter Trommler committed
27
   The way the compiler "knows about" one of these things is
Thomas Schilling's avatar
Thomas Schilling committed
28 29 30 31
   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
Note [Known-key names]
~~~~~~~~~~~~~~~~~~~~~~
40 41 42
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:
43

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

47 48
  2. When we read an interface file, the read-in gubbins better have
     the right uniques
49 50 51

This is accomplished through a combination of mechanisms:

52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
  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 isBuiltInOcc_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 "OrigNameCache" 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.

76 77
  3. For "infinite families" of known-key names (i.e. tuples and sums), we
     have to be extra careful. Because there are an infinite number of
78 79
     these things, we cannot add them to the list of known-key names
     used to initialise the OrigNameCache. Instead, we have to
80 81
     rely on never having to look them up in that cache. See
     Note [Infinite families of known-key names] for details.
82 83


84 85 86 87 88 89
Note [Infinite families of known-key names]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Infinite families of known-key things (e.g. tuples and sums) pose a tricky
problem: we can't add them to the knownKeyNames finite map which we use to
ensure that, e.g., a reference to (,) gets assigned the right unique (if this
doesn't sound familiar see Note [Known-key names] above).
90

91 92
We instead handle tuples and sums separately from the "vanilla" known-key
things,
93

94 95
  a) The parser recognises them specially and generates an Exact Name (hence not
     looked up in the orig-name cache)
96

97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
  b) 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. See Note [Symbol table
     representation of names] in BinIface and Note [How tuples work] in
     TysWiredIn.

Most of the infinite families cannot occur in source code, so mechanisms (a) and (b)
suffice 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. For those things that *can* appear in source programs,

  c) IfaceEnv.lookupOrigNameCache uses isBuiltInOcc_maybe to map built-in syntax
     directly onto the corresponding name, rather than trying to find it in the
     original-name cache.

     See also Note [Built-in syntax and the OrigNameCache]
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142


Note [The integer library]
~~~~~~~~~~~~~~~~~~~~~~~~~~

Clearly, we need to know the names of various definitions of the integer
library, e.g. the type itself, `mkInteger` etc. But there are two possible
implementations of the integer library:

 * integer-gmp (fast, but uses libgmp, which may not be available on all
   targets and is GPL licensed)
 * integer-simple (slow, but pure Haskell and BSD-licensed)

We want the compiler to work with either one. The way we achieve this is:

 * When compiling the integer-{gmp,simple} library, we pass
     -this-unit-id  integer-wired-in
   to GHC (see the cabal file libraries/integer-{gmp,simple}.
 * This way, GHC can use just this UnitID (see Module.integerUnitId) when
   generating code, and the linker will succeed.

Unfortuately, the abstraction is not complete: When using integer-gmp, we
really want to use the S# constructor directly. This is controlled by
the `integerLibrary` field of `DynFlags`: If it is IntegerGMP, we use
this constructor directly (see  CorePrep.lookupIntegerSDataConName)

When GHC reads the package data base, it (internally only) pretends it has UnitId
`integer-wired-in` instead of the actual UnitId (which includes the version
number); just like for `base` and other packages, as described in
Note [Wired-in packages] in Module. This is done in Packages.findWiredInPackages.
Austin Seipp's avatar
Austin Seipp committed
143
-}
144

145 146
{-# LANGUAGE CPP #-}

147
module PrelNames (
148 149 150 151 152 153 154 155
        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
156
    ) where
157 158 159

#include "HsVersions.h"

160 161
import GhcPrelude

162
import Module
Ian Lynagh's avatar
Ian Lynagh committed
163
import OccName
164 165 166
import RdrName
import Unique
import Name
167
import SrcLoc
168
import FastString
169

Austin Seipp's avatar
Austin Seipp committed
170 171 172
{-
************************************************************************
*                                                                      *
173
     allNameStrings
Austin Seipp's avatar
Austin Seipp committed
174 175 176
*                                                                      *
************************************************************************
-}
177 178 179

allNameStrings :: [String]
-- Infinite list of a,b,c...z, aa, ab, ac, ... etc
180
allNameStrings = [ c:cs | cs <- "" : allNameStrings, c <- ['a'..'z'] ]
181

Austin Seipp's avatar
Austin Seipp committed
182 183 184
{-
************************************************************************
*                                                                      *
185
\subsection{Local Names}
Austin Seipp's avatar
Austin Seipp committed
186 187
*                                                                      *
************************************************************************
188 189

This *local* name is used by the interactive stuff
Austin Seipp's avatar
Austin Seipp committed
190
-}
191

192 193
itName :: Unique -> SrcSpan -> Name
itName uniq loc = mkInternalName uniq (mkOccNameFS varName (fsLit "it")) loc
194 195 196

-- mkUnboundName makes a place-holder Name; it shouldn't be looked at except possibly
-- during compiler debugging.
197 198
mkUnboundName :: OccName -> Name
mkUnboundName occ = mkInternalName unboundKey occ noSrcSpan
199 200 201 202

isUnboundName :: Name -> Bool
isUnboundName name = name `hasKey` unboundKey

Austin Seipp's avatar
Austin Seipp committed
203 204 205
{-
************************************************************************
*                                                                      *
206
\subsection{Known key Names}
Austin Seipp's avatar
Austin Seipp committed
207 208
*                                                                      *
************************************************************************
209

210
This section tells what the compiler knows about the association of
211 212
names with uniques.  These ones are the *non* wired-in ones.  The
wired in ones are defined in TysWiredIn etc.
Austin Seipp's avatar
Austin Seipp committed
213
-}
214

Simon Peyton Jones's avatar
Simon Peyton Jones committed
215
basicKnownKeyNames :: [Name]  -- See Note [Known-key names]
216
basicKnownKeyNames
217
 = genericTyConNames
Ben Gamari's avatar
Ben Gamari committed
218
 ++ [   --  Classes.  *Must* include:
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
        --      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,
237
        alternativeClassName,
238 239
        foldableClassName,
        traversableClassName,
240 241
        semigroupClassName, sappendName,
        monoidClassName, memptyName, mappendName, mconcatName,
242

Ben Gamari's avatar
Ben Gamari committed
243 244 245 246
        -- The IO type
        -- See Note [TyConRepNames for non-wired-in TyCons]
        ioTyConName, ioDataConName,
        runMainIOName,
Simon Peyton Jones's avatar
Simon Peyton Jones committed
247
        runRWName,
Ben Gamari's avatar
Ben Gamari committed
248

249 250 251 252 253
        -- Type representation types
        trModuleTyConName, trModuleDataConName,
        trNameTyConName, trNameSDataConName, trNameDDataConName,
        trTyConTyConName, trTyConDataConName,

254 255 256
        -- Typeable
        typeableClassName,
        typeRepTyConName,
Ben Gamari's avatar
Ben Gamari committed
257 258 259 260 261 262 263 264 265 266 267 268 269
        someTypeRepTyConName,
        someTypeRepDataConName,
        kindRepTyConName,
        kindRepTyConAppDataConName,
        kindRepVarDataConName,
        kindRepAppDataConName,
        kindRepFunDataConName,
        kindRepTYPEDataConName,
        kindRepTypeLitSDataConName,
        kindRepTypeLitDDataConName,
        typeLitSortTyConName,
        typeLitSymbolDataConName,
        typeLitNatDataConName,
270
        typeRepIdName,
David Feuer's avatar
David Feuer committed
271
        mkTrTypeName,
Ben Gamari's avatar
Ben Gamari committed
272 273 274
        mkTrConName,
        mkTrAppName,
        mkTrFunName,
275
        typeSymbolTypeRepName, typeNatTypeRepName,
276
        trGhcPrimModuleName,
277

278 279 280 281 282
        -- KindReps for common cases
        starKindRepName,
        starArrStarKindRepName,
        starArrStarArrStarKindRepName,

283 284
        -- Dynamic
        toDynName,
285 286

        -- Numeric stuff
287 288 289
        negateName, minusName, geName, eqName,

        -- Conversion functions
Ben Gamari's avatar
Ben Gamari committed
290 291
        rationalTyConName,
        ratioTyConName, ratioDataConName,
292 293 294
        fromRationalName, fromIntegerName,
        toIntegerName, toRationalName,
        fromIntegralName, realToFracName,
295

296 297 298
        -- Int# stuff
        divIntName, modIntName,

299 300
        -- String stuff
        fromStringName,
301 302 303 304 305

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

306 307
        -- Applicative stuff
        pureAName, apAName, thenAName,
308

David Feuer's avatar
David Feuer committed
309 310 311
        -- Functor stuff
        fmapName,

312
        -- Monad stuff
quchen's avatar
quchen committed
313
        thenIOName, bindIOName, returnIOName, failIOName, bindMName, thenMName,
David Feuer's avatar
David Feuer committed
314
        returnMName, joinMName,
quchen's avatar
quchen committed
315 316

        -- MonadFail
317
        monadFailClassName, failMName,
318

319 320
        -- MonadFix
        monadFixClassName, mfixName,
321

322 323 324
        -- Arrow stuff
        arrAName, composeAName, firstAName,
        appAName, choiceAName, loopAName,
325

326 327
        -- Ix stuff
        ixClassName,
328

329 330
        -- Show stuff
        showClassName,
331

332 333
        -- Read stuff
        readClassName,
334

335 336
        -- Stable pointers
        newStablePtrName,
337

338
        -- GHC Extensions
339
        groupWithName,
340

341 342 343
        -- Strings and lists
        unpackCStringName,
        unpackCStringFoldrName, unpackCStringUtf8Name,
344

345 346 347 348 349
        -- Overloaded lists
        isListClassName,
        fromListName,
        fromListNName,
        toListName,
350

351 352 353
        -- List operations
        concatName, filterName, mapName,
        zipName, foldrName, buildName, augmentName, appendName,
354

355 356 357
        -- FFI primitive types that are not wired-in.
        stablePtrTyConName, ptrTyConName, funPtrTyConName,
        int8TyConName, int16TyConName, int32TyConName, int64TyConName,
358
        word16TyConName, word32TyConName, word64TyConName,
359

360 361 362
        -- Others
        otherwiseIdName, inlineIdName,
        eqStringName, assertName, breakpointName, breakpointCondName,
363
        opaqueTyConName,
David Feuer's avatar
David Feuer committed
364
        assertErrorName, traceName,
365
        printName, fstName, sndName,
Simon Peyton Jones's avatar
Simon Peyton Jones committed
366
        dollarName,
367

368
        -- Integer
369
        integerTyConName, mkIntegerName,
370
        integerToWord64Name, integerToInt64Name,
Ian Lynagh's avatar
Ian Lynagh committed
371
        word64ToIntegerName, int64ToIntegerName,
372
        plusIntegerName, timesIntegerName, smallIntegerName,
373
        wordToIntegerName,
374
        integerToWordName, integerToIntName, minusIntegerName,
375
        negateIntegerName, eqIntegerPrimName, neqIntegerPrimName,
376
        absIntegerName, signumIntegerName,
377
        leIntegerPrimName, gtIntegerPrimName, ltIntegerPrimName, geIntegerPrimName,
Ian Lynagh's avatar
Ian Lynagh committed
378
        compareIntegerName, quotRemIntegerName, divModIntegerName,
379
        quotIntegerName, remIntegerName, divIntegerName, modIntegerName,
380
        floatFromIntegerName, doubleFromIntegerName,
381
        encodeFloatIntegerName, encodeDoubleIntegerName,
Ian Lynagh's avatar
Ian Lynagh committed
382
        decodeDoubleIntegerName,
383 384
        gcdIntegerName, lcmIntegerName,
        andIntegerName, orIntegerName, xorIntegerName, complementIntegerName,
385
        shiftLIntegerName, shiftRIntegerName, bitIntegerName,
386
        integerSDataConName,naturalSDataConName,
387

388 389
        -- Natural
        naturalTyConName,
390 391 392
        naturalFromIntegerName, naturalToIntegerName,
        plusNaturalName, minusNaturalName, timesNaturalName, mkNaturalName,
        wordToNaturalName,
393

394 395 396 397
        -- Float/Double
        rationalToFloatName,
        rationalToDoubleName,

398 399
        -- Other classes
        randomClassName, randomGenClassName, monadPlusClassName,
400

401
        -- Type-level naturals
402
        knownNatClassName, knownSymbolClassName,
403

Adam Gundry's avatar
Adam Gundry committed
404 405 406
        -- Overloaded labels
        isLabelClassName,

407 408 409
        -- Implicit Parameters
        ipClassName,

410 411 412
        -- Overloaded record fields
        hasFieldClassName,

413 414
        -- Call Stacks
        callStackTyConName,
Eric Seidel's avatar
Eric Seidel committed
415
        emptyCallStackName, pushCallStackName,
416 417

        -- Source Locations
418 419
        srcLocDataConName,

420
        -- Annotation type checking
421
        toAnnotationWrapperName
422

423
        -- The Ordering type
Ben Gamari's avatar
Ben Gamari committed
424
        , orderingTyConName
425
        , ordLTDataConName, ordEQDataConName, ordGTDataConName
426

427 428 429
        -- The SPEC type for SpecConstr
        , specTyConName

430 431
        -- The Either type
        , eitherTyConName, leftDataConName, rightDataConName
432

433 434
        -- Plugins
        , pluginTyConName
Edward Z. Yang's avatar
Edward Z. Yang committed
435
        , frontendPluginTyConName
436 437 438 439 440

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

441 442 443 444
        -- Monad comprehensions
        , guardMName
        , liftMName
        , mzipName
dterei's avatar
dterei committed
445 446 447

        -- GHCi Sandbox
        , ghciIoClassName, ghciStepIoMName
Facundo Domínguez's avatar
Facundo Domínguez committed
448 449

        -- StaticPtr
450
        , makeStaticName
Facundo Domínguez's avatar
Facundo Domínguez committed
451 452
        , staticPtrTyConName
        , staticPtrDataConName, staticPtrInfoDataConName
453
        , fromStaticPtrName
Facundo Domínguez's avatar
Facundo Domínguez committed
454 455 456 457

        -- Fingerprint
        , fingerprintDataConName

458 459 460 461 462 463 464
        -- Custom type errors
        , errorMessageTypeErrorFamName
        , typeErrorTextDataConName
        , typeErrorAppendDataConName
        , typeErrorVAppendDataConName
        , typeErrorShowTypeDataConName

465
    ]
466

467
genericTyConNames :: [Name]
468 469 470
genericTyConNames = [
    v1TyConName, u1TyConName, par1TyConName, rec1TyConName,
    k1TyConName, m1TyConName, sumTyConName, prodTyConName,
471 472
    compTyConName, rTyConName, dTyConName,
    cTyConName, sTyConName, rec0TyConName,
473
    d1TyConName, c1TyConName, s1TyConName, noSelTyConName,
474 475
    repTyConName, rep1TyConName, uRecTyConName,
    uAddrTyConName, uCharTyConName, uDoubleTyConName,
476 477 478
    uFloatTyConName, uIntTyConName, uWordTyConName,
    prefixIDataConName, infixIDataConName, leftAssociativeDataConName,
    rightAssociativeDataConName, notAssociativeDataConName,
479 480 481 482 483
    sourceUnpackDataConName, sourceNoUnpackDataConName,
    noSourceUnpackednessDataConName, sourceLazyDataConName,
    sourceStrictDataConName, noSourceStrictnessDataConName,
    decidedLazyDataConName, decidedStrictDataConName, decidedUnpackDataConName,
    metaDataDataConName, metaConsDataConName, metaSelDataConName
484
  ]
485

Austin Seipp's avatar
Austin Seipp committed
486 487 488
{-
************************************************************************
*                                                                      *
489
\subsection{Module names}
Austin Seipp's avatar
Austin Seipp committed
490 491
*                                                                      *
************************************************************************
492

493 494

--MetaHaskell Extension Add a new module here
Austin Seipp's avatar
Austin Seipp committed
495 496
-}

Ian Lynagh's avatar
Ian Lynagh committed
497
pRELUDE :: Module
498
pRELUDE         = mkBaseModule_ pRELUDE_NAME
Ian Lynagh's avatar
Ian Lynagh committed
499

Joachim Breitner's avatar
Joachim Breitner committed
500
gHC_PRIM, gHC_TYPES, gHC_GENERICS, gHC_MAGIC,
501 502
    gHC_CLASSES, gHC_PRIMOPWRAPPERS, gHC_BASE, gHC_ENUM,
    gHC_GHCI, gHC_GHCI_HELPERS, gHC_CSTRING,
503 504
    gHC_SHOW, gHC_READ, gHC_NUM, gHC_MAYBE, gHC_INTEGER_TYPE, gHC_NATURAL,
    gHC_LIST, gHC_TUPLE, dATA_TUPLE, dATA_EITHER, dATA_STRING,
505
    dATA_FOLDABLE, dATA_TRAVERSABLE,
dterei's avatar
dterei committed
506 507
    gHC_CONC, gHC_IO, gHC_IO_Exception,
    gHC_ST, gHC_ARR, gHC_STABLE, gHC_PTR, gHC_ERR, gHC_REAL,
508
    gHC_FLOAT, gHC_TOP_HANDLER, sYSTEM_IO, dYNAMIC,
509
    tYPEABLE, tYPEABLE_INTERNAL, gENERICS,
quchen's avatar
quchen committed
510
    rEAD_PREC, lEX, gHC_INT, gHC_WORD, mONAD, mONAD_FIX, mONAD_ZIP, mONAD_FAIL,
511
    aRROW, cONTROL_APPLICATIVE, gHC_DESUGAR, rANDOM, gHC_EXTS,
512
    cONTROL_EXCEPTION_BASE, gHC_TYPELITS, gHC_TYPENATS, dATA_TYPE_EQUALITY,
David Feuer's avatar
David Feuer committed
513
    dATA_COERCE, dEBUG_TRACE :: Module
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
514

515
gHC_PRIM        = mkPrimModule (fsLit "GHC.Prim")   -- Primitive types and values
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
516
gHC_TYPES       = mkPrimModule (fsLit "GHC.Types")
517 518 519
gHC_MAGIC       = mkPrimModule (fsLit "GHC.Magic")
gHC_CSTRING     = mkPrimModule (fsLit "GHC.CString")
gHC_CLASSES     = mkPrimModule (fsLit "GHC.Classes")
520
gHC_PRIMOPWRAPPERS = mkPrimModule (fsLit "GHC.PrimopWrappers")
521 522 523

gHC_BASE        = mkBaseModule (fsLit "GHC.Base")
gHC_ENUM        = mkBaseModule (fsLit "GHC.Enum")
dterei's avatar
dterei committed
524
gHC_GHCI        = mkBaseModule (fsLit "GHC.GHCi")
525
gHC_GHCI_HELPERS= mkBaseModule (fsLit "GHC.GHCi.Helpers")
526 527 528
gHC_SHOW        = mkBaseModule (fsLit "GHC.Show")
gHC_READ        = mkBaseModule (fsLit "GHC.Read")
gHC_NUM         = mkBaseModule (fsLit "GHC.Num")
529
gHC_MAYBE       = mkBaseModule (fsLit "GHC.Maybe")
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
530
gHC_INTEGER_TYPE= mkIntegerModule (fsLit "GHC.Integer.Type")
531
gHC_NATURAL     = mkBaseModule (fsLit "GHC.Natural")
532 533 534
gHC_LIST        = mkBaseModule (fsLit "GHC.List")
gHC_TUPLE       = mkPrimModule (fsLit "GHC.Tuple")
dATA_TUPLE      = mkBaseModule (fsLit "Data.Tuple")
535 536 537
dATA_EITHER     = mkBaseModule (fsLit "Data.Either")
dATA_STRING     = mkBaseModule (fsLit "Data.String")
dATA_FOLDABLE   = mkBaseModule (fsLit "Data.Foldable")
538
dATA_TRAVERSABLE= mkBaseModule (fsLit "Data.Traversable")
539 540
gHC_CONC        = mkBaseModule (fsLit "GHC.Conc")
gHC_IO          = mkBaseModule (fsLit "GHC.IO")
541
gHC_IO_Exception = mkBaseModule (fsLit "GHC.IO.Exception")
542 543 544 545 546 547 548 549 550 551
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")
552 553
tYPEABLE        = mkBaseModule (fsLit "Data.Typeable")
tYPEABLE_INTERNAL = mkBaseModule (fsLit "Data.Typeable.Internal")
554
gENERICS        = mkBaseModule (fsLit "Data.Data")
555 556 557 558 559 560
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")
561
mONAD_ZIP       = mkBaseModule (fsLit "Control.Monad.Zip")
quchen's avatar
quchen committed
562
mONAD_FAIL      = mkBaseModule (fsLit "Control.Monad.Fail")
563
aRROW           = mkBaseModule (fsLit "Control.Arrow")
564
cONTROL_APPLICATIVE = mkBaseModule (fsLit "Control.Applicative")
Ian Lynagh's avatar
Ian Lynagh committed
565
gHC_DESUGAR = mkBaseModule (fsLit "GHC.Desugar")
566 567
rANDOM          = mkBaseModule (fsLit "System.Random")
gHC_EXTS        = mkBaseModule (fsLit "GHC.Exts")
568
cONTROL_EXCEPTION_BASE = mkBaseModule (fsLit "Control.Exception.Base")
jpm@cs.ox.ac.uk's avatar
jpm@cs.ox.ac.uk committed
569
gHC_GENERICS    = mkBaseModule (fsLit "GHC.Generics")
570
gHC_TYPELITS    = mkBaseModule (fsLit "GHC.TypeLits")
571
gHC_TYPENATS    = mkBaseModule (fsLit "GHC.TypeNats")
572 573
dATA_TYPE_EQUALITY = mkBaseModule (fsLit "Data.Type.Equality")
dATA_COERCE     = mkBaseModule (fsLit "Data.Coerce")
David Feuer's avatar
David Feuer committed
574
dEBUG_TRACE     = mkBaseModule (fsLit "Debug.Trace")
Simon Marlow's avatar
Simon Marlow committed
575

576 577 578
gHC_SRCLOC :: Module
gHC_SRCLOC = mkBaseModule (fsLit "GHC.SrcLoc")

Ben Gamari's avatar
Ben Gamari committed
579
gHC_STACK, gHC_STACK_TYPES :: Module
580
gHC_STACK = mkBaseModule (fsLit "GHC.Stack")
Ben Gamari's avatar
Ben Gamari committed
581
gHC_STACK_TYPES = mkBaseModule (fsLit "GHC.Stack.Types")
582

Facundo Domínguez's avatar
Facundo Domínguez committed
583 584 585
gHC_STATICPTR :: Module
gHC_STATICPTR = mkBaseModule (fsLit "GHC.StaticPtr")

586 587 588
gHC_STATICPTR_INTERNAL :: Module
gHC_STATICPTR_INTERNAL = mkBaseModule (fsLit "GHC.StaticPtr.Internal")

Facundo Domínguez's avatar
Facundo Domínguez committed
589 590 591
gHC_FINGERPRINT_TYPE :: Module
gHC_FINGERPRINT_TYPE = mkBaseModule (fsLit "GHC.Fingerprint.Type")

Adam Gundry's avatar
Adam Gundry committed
592 593 594
gHC_OVER_LABELS :: Module
gHC_OVER_LABELS = mkBaseModule (fsLit "GHC.OverloadedLabels")

595 596 597
gHC_RECORDS :: Module
gHC_RECORDS = mkBaseModule (fsLit "GHC.Records")

Ian Lynagh's avatar
Ian Lynagh committed
598
mAIN, rOOT_MAIN :: Module
599 600
mAIN            = mkMainModule_ mAIN_NAME
rOOT_MAIN       = mkMainModule (fsLit ":Main") -- Root module for initialisation
Simon Marlow's avatar
Simon Marlow committed
601

602 603
mkInteractiveModule :: Int -> Module
-- (mkInteractiveMoudule 9) makes module 'interactive:M9'
604
mkInteractiveModule n = mkModule interactiveUnitId (mkModuleName ("Ghci" ++ show n))
Simon Marlow's avatar
Simon Marlow committed
605

Ian Lynagh's avatar
Ian Lynagh committed
606
pRELUDE_NAME, mAIN_NAME :: ModuleName
Ian Lynagh's avatar
Ian Lynagh committed
607 608
pRELUDE_NAME   = mkModuleNameFS (fsLit "Prelude")
mAIN_NAME      = mkModuleNameFS (fsLit "Main")
Simon Marlow's avatar
Simon Marlow committed
609

610 611 612 613
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
614
mkPrimModule :: FastString -> Module
615
mkPrimModule m = mkModule primUnitId (mkModuleNameFS m)
Ian Lynagh's avatar
Ian Lynagh committed
616 617

mkIntegerModule :: FastString -> Module
618
mkIntegerModule m = mkModule integerUnitId (mkModuleNameFS m)
Ian Lynagh's avatar
Ian Lynagh committed
619

Simon Marlow's avatar
Simon Marlow committed
620
mkBaseModule :: FastString -> Module
621
mkBaseModule m = mkModule baseUnitId (mkModuleNameFS m)
Simon Marlow's avatar
Simon Marlow committed
622 623

mkBaseModule_ :: ModuleName -> Module
624
mkBaseModule_ m = mkModule baseUnitId m
Simon Marlow's avatar
Simon Marlow committed
625

626
mkThisGhcModule :: FastString -> Module
627
mkThisGhcModule m = mkModule thisGhcUnitId (mkModuleNameFS m)
628 629

mkThisGhcModule_ :: ModuleName -> Module
630
mkThisGhcModule_ m = mkModule thisGhcUnitId m
631

Simon Marlow's avatar
Simon Marlow committed
632
mkMainModule :: FastString -> Module
633
mkMainModule m = mkModule mainUnitId (mkModuleNameFS m)
634

Simon Marlow's avatar
Simon Marlow committed
635
mkMainModule_ :: ModuleName -> Module
636
mkMainModule_ m = mkModule mainUnitId m
637

Austin Seipp's avatar
Austin Seipp committed
638 639 640
{-
************************************************************************
*                                                                      *
641
                        RdrNames
Austin Seipp's avatar
Austin Seipp committed
642 643 644
*                                                                      *
************************************************************************
-}
645

Ian Lynagh's avatar
Ian Lynagh committed
646
main_RDR_Unqual    :: RdrName
647 648 649
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
650

David Feuer's avatar
David Feuer committed
651
eq_RDR, ge_RDR, le_RDR, lt_RDR, gt_RDR, compare_RDR,
Ian Lynagh's avatar
Ian Lynagh committed
652
    ltTag_RDR, eqTag_RDR, gtTag_RDR :: RdrName
653 654 655 656 657 658
eq_RDR                  = nameRdrName eqName
ge_RDR                  = nameRdrName geName
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")
659 660 661
ltTag_RDR               = nameRdrName  ordLTDataConName
eqTag_RDR               = nameRdrName  ordEQDataConName
gtTag_RDR               = nameRdrName  ordGTDataConName
662

Ian Lynagh's avatar
Ian Lynagh committed
663 664
eqClass_RDR, numClass_RDR, ordClass_RDR, enumClass_RDR, monadClass_RDR
    :: RdrName
665 666 667 668 669
eqClass_RDR             = nameRdrName eqClassName
numClass_RDR            = nameRdrName numClassName
ordClass_RDR            = nameRdrName ordClassName
enumClass_RDR           = nameRdrName enumClassName
monadClass_RDR          = nameRdrName monadClassName
670

Ian Lynagh's avatar
Ian Lynagh committed
671
map_RDR, append_RDR :: RdrName
672 673
map_RDR                 = nameRdrName mapName
append_RDR              = nameRdrName appendName
674

675 676
foldr_RDR, build_RDR, returnM_RDR, bindM_RDR, failM_RDR
    :: RdrName
677 678 679 680 681
foldr_RDR               = nameRdrName foldrName
build_RDR               = nameRdrName buildName
returnM_RDR             = nameRdrName returnMName
bindM_RDR               = nameRdrName bindMName
failM_RDR               = nameRdrName failMName
682

Ian Lynagh's avatar
Ian Lynagh committed
683
left_RDR, right_RDR :: RdrName
684 685
left_RDR                = nameRdrName leftDataConName
right_RDR               = nameRdrName rightDataConName
686

Ian Lynagh's avatar
Ian Lynagh committed
687
fromEnum_RDR, toEnum_RDR :: RdrName
688 689
fromEnum_RDR            = varQual_RDR gHC_ENUM (fsLit "fromEnum")
toEnum_RDR              = varQual_RDR gHC_ENUM (fsLit "toEnum")
690

Ian Lynagh's avatar
Ian Lynagh committed
691
enumFrom_RDR, enumFromTo_RDR, enumFromThen_RDR, enumFromThenTo_RDR :: RdrName
692 693 694 695
enumFrom_RDR            = nameRdrName enumFromName
enumFromTo_RDR          = nameRdrName enumFromToName
enumFromThen_RDR        = nameRdrName enumFromThenName
enumFromThenTo_RDR      = nameRdrName enumFromThenToName
696

Ian Lynagh's avatar
Ian Lynagh committed
697
ratioDataCon_RDR, plusInteger_RDR, timesInteger_RDR :: RdrName
698 699 700
ratioDataCon_RDR        = nameRdrName ratioDataConName
plusInteger_RDR         = nameRdrName plusIntegerName
timesInteger_RDR        = nameRdrName timesIntegerName
701

Ian Lynagh's avatar
Ian Lynagh committed
702
ioDataCon_RDR :: RdrName
703
ioDataCon_RDR           = nameRdrName ioDataConName
704

Ian Lynagh's avatar
Ian Lynagh committed
705 706
eqString_RDR, unpackCString_RDR, unpackCStringFoldr_RDR,
    unpackCStringUtf8_RDR :: RdrName
707 708 709 710
eqString_RDR            = nameRdrName eqStringName
unpackCString_RDR       = nameRdrName unpackCStringName
unpackCStringFoldr_RDR  = nameRdrName unpackCStringFoldrName
unpackCStringUtf8_RDR   = nameRdrName unpackCStringUtf8Name
711

712
newStablePtr_RDR :: RdrName
713
newStablePtr_RDR        = nameRdrName newStablePtrName
714

Ian Lynagh's avatar
Ian Lynagh committed
715
bindIO_RDR, returnIO_RDR :: RdrName
716 717
bindIO_RDR              = nameRdrName bindIOName
returnIO_RDR            = nameRdrName returnIOName
718

Ian Lynagh's avatar
Ian Lynagh committed
719
fromInteger_RDR, fromRational_RDR, minus_RDR, times_RDR, plus_RDR :: RdrName
720 721 722 723
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
724
plus_RDR                = varQual_RDR gHC_NUM (fsLit "+")
Simon Marlow's avatar
Simon Marlow committed
725

Ryan Scott's avatar
Ryan Scott committed
726 727 728 729 730
toInteger_RDR, toRational_RDR, fromIntegral_RDR :: RdrName
toInteger_RDR           = nameRdrName toIntegerName
toRational_RDR          = nameRdrName toRationalName
fromIntegral_RDR        = nameRdrName fromIntegralName

731 732
stringTy_RDR, fromString_RDR :: RdrName
stringTy_RDR            = tcQual_RDR gHC_BASE (fsLit "String")
733
fromString_RDR          = nameRdrName fromStringName
734

735 736 737 738 739
fromList_RDR, fromListN_RDR, toList_RDR :: RdrName
fromList_RDR = nameRdrName fromListName
fromListN_RDR = nameRdrName fromListNName
toList_RDR = nameRdrName toListName

Ian Lynagh's avatar
Ian Lynagh committed
740
compose_RDR :: RdrName
741
compose_RDR             = varQual_RDR gHC_BASE (fsLit ".")
Simon Marlow's avatar
Simon Marlow committed
742

Ian Lynagh's avatar
Ian Lynagh committed
743
not_RDR, getTag_RDR, succ_RDR, pred_RDR, minBound_RDR, maxBound_RDR,
744
    and_RDR, range_RDR, inRange_RDR, index_RDR,
Ian Lynagh's avatar
Ian Lynagh committed
745
    unsafeIndex_RDR, unsafeRangeSize_RDR :: RdrName
746 747 748 749
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
750 751 752 753 754
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")
755 756 757
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
758

Ian Lynagh's avatar
Ian Lynagh committed
759
readList_RDR, readListDefault_RDR, readListPrec_RDR, readListPrecDefault_RDR,
760
    readPrec_RDR, parens_RDR, choose_RDR, lexP_RDR, expectP_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
761 762 763 764 765 766 767 768
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")
769
expectP_RDR             = varQual_RDR gHC_READ (fsLit "expectP")
770

771
readField_RDR, readFieldHash_RDR, readSymField_RDR :: RdrName
Tobias Dammers's avatar
Tobias Dammers committed
772
readField_RDR           = varQual_RDR gHC_READ (fsLit "readField")
773
readFieldHash_RDR       = varQual_RDR gHC_READ (fsLit "readFieldHash")
Tobias Dammers's avatar
Tobias Dammers committed
774 775
readSymField_RDR        = varQual_RDR gHC_READ (fsLit "readSymField")

Ian Lynagh's avatar
Ian Lynagh committed
776
punc_RDR, ident_RDR, symbol_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
777 778 779
punc_RDR                = dataQual_RDR lEX (fsLit "Punc")
ident_RDR               = dataQual_RDR lEX (fsLit "Ident")
symbol_RDR              = dataQual_RDR lEX (fsLit "Symbol")
780

781
step_RDR, alt_RDR, reset_RDR, prec_RDR, pfail_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
782
step_RDR                = varQual_RDR  rEAD_PREC (fsLit "step")
783
alt_RDR                 = varQual_RDR  rEAD_PREC (fsLit "+++")
Ian Lynagh's avatar
Ian Lynagh committed
784 785
reset_RDR               = varQual_RDR  rEAD_PREC (fsLit "reset")
prec_RDR                = varQual_RDR  rEAD_PREC (fsLit "prec")
786
pfail_RDR               = varQual_RDR  rEAD_PREC (fsLit "pfail")
787

David Feuer's avatar
David Feuer committed
788
showsPrec_RDR, shows_RDR, showString_RDR,
Ben Gamari's avatar
Ben Gamari committed
789
    showSpace_RDR, showCommaSpace_RDR, showParen_RDR :: RdrName
790
showsPrec_RDR           = varQual_RDR gHC_SHOW (fsLit "showsPrec")
thomie's avatar
thomie committed
791
shows_RDR               = varQual_RDR gHC_SHOW (fsLit "shows")
Ian Lynagh's avatar
Ian Lynagh committed
792
showString_RDR          = varQual_RDR gHC_SHOW (fsLit "showString")
793
showSpace_RDR           = varQual_RDR gHC_SHOW (fsLit "showSpace")
Ben Gamari's avatar
Ben Gamari committed
794
showCommaSpace_RDR      = varQual_RDR gHC_SHOW (fsLit "showCommaSpace")
795
showParen_RDR           = varQual_RDR gHC_SHOW (fsLit "showParen")
796

Ian Lynagh's avatar
Ian Lynagh committed
797
undefined_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
798
undefined_RDR = varQual_RDR gHC_ERR (fsLit "undefined")
799

800 801 802 803 804 805
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,
jpm@cs.ox.ac.uk's avatar
jpm@cs.ox.ac.uk committed
806 807 808
  prodDataCon_RDR, comp1DataCon_RDR,
  unPar1_RDR, unRec1_RDR, unK1_RDR, unComp1_RDR,
  from_RDR, from1_RDR, to_RDR, to1_RDR,
809
  datatypeName_RDR, moduleName_RDR, packageName_RDR, isNewtypeName_RDR,
810
  conName_RDR, conFixity_RDR