PrelNames.hs 100 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
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
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
Note [Infinite families of known-key names]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86

87 88 89 90
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).
91

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

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

98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
  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]
Austin Seipp's avatar
Austin Seipp committed
114
-}
115

116 117
{-# LANGUAGE CPP #-}

118
module PrelNames (
119 120 121 122 123 124 125 126
        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
127
    ) where
128 129 130

#include "HsVersions.h"

131
import Module
Ian Lynagh's avatar
Ian Lynagh committed
132
import OccName
133 134 135
import RdrName
import Unique
import Name
136
import SrcLoc
137
import FastString
138 139
import Config ( cIntegerLibraryType, IntegerLibrary(..) )
import Panic ( panic )
140

Austin Seipp's avatar
Austin Seipp committed
141 142 143
{-
************************************************************************
*                                                                      *
144
     allNameStrings
Austin Seipp's avatar
Austin Seipp committed
145 146 147
*                                                                      *
************************************************************************
-}
148 149 150

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

Austin Seipp's avatar
Austin Seipp committed
153 154 155
{-
************************************************************************
*                                                                      *
156
\subsection{Local Names}
Austin Seipp's avatar
Austin Seipp committed
157 158
*                                                                      *
************************************************************************
159 160

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

163 164
itName :: Unique -> SrcSpan -> Name
itName uniq loc = mkInternalName uniq (mkOccNameFS varName (fsLit "it")) loc
165 166 167

-- mkUnboundName makes a place-holder Name; it shouldn't be looked at except possibly
-- during compiler debugging.
168 169
mkUnboundName :: OccName -> Name
mkUnboundName occ = mkInternalName unboundKey occ noSrcSpan
170 171 172 173

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

Austin Seipp's avatar
Austin Seipp committed
174 175 176
{-
************************************************************************
*                                                                      *
177
\subsection{Known key Names}
Austin Seipp's avatar
Austin Seipp committed
178 179
*                                                                      *
************************************************************************
180

181
This section tells what the compiler knows about the association of
182 183
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
184
-}
185

186 187
basicKnownKeyNames :: [Name]
basicKnownKeyNames
188
 = genericTyConNames
Ben Gamari's avatar
Ben Gamari committed
189
 ++ [   --  Classes.  *Must* include:
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
        --      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,
208
        alternativeClassName,
209 210
        foldableClassName,
        traversableClassName,
211 212
        semigroupClassName, sappendName,
        monoidClassName, memptyName, mappendName, mconcatName,
213

Ben Gamari's avatar
Ben Gamari committed
214 215 216 217 218
        -- The IO type
        -- See Note [TyConRepNames for non-wired-in TyCons]
        ioTyConName, ioDataConName,
        runMainIOName,

219 220 221 222 223
        -- Type representation types
        trModuleTyConName, trModuleDataConName,
        trNameTyConName, trNameSDataConName, trNameDDataConName,
        trTyConTyConName, trTyConDataConName,

224 225 226
        -- Typeable
        typeableClassName,
        typeRepTyConName,
227
        typeRepIdName,
228 229
        mkPolyTyConAppName,
        mkAppTyName,
230
        typeSymbolTypeRepName, typeNatTypeRepName,
231
        trGhcPrimModuleName,
232

233 234
        -- Dynamic
        toDynName,
235 236

        -- Numeric stuff
237 238 239
        negateName, minusName, geName, eqName,

        -- Conversion functions
Ben Gamari's avatar
Ben Gamari committed
240 241
        rationalTyConName,
        ratioTyConName, ratioDataConName,
242 243 244
        fromRationalName, fromIntegerName,
        toIntegerName, toRationalName,
        fromIntegralName, realToFracName,
245

246 247 248
        -- Int# stuff
        divIntName, modIntName,

249 250
        -- String stuff
        fromStringName,
251 252 253 254 255

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

256 257
        -- Applicative stuff
        pureAName, apAName, thenAName,
258

259
        -- Monad stuff
quchen's avatar
quchen committed
260 261 262 263 264
        thenIOName, bindIOName, returnIOName, failIOName, bindMName, thenMName,
        returnMName, fmapName, joinMName,

        -- MonadFail
        monadFailClassName, failMName, failMName_preMFP,
265

266 267
        -- MonadFix
        monadFixClassName, mfixName,
268

269 270 271
        -- Arrow stuff
        arrAName, composeAName, firstAName,
        appAName, choiceAName, loopAName,
272

273 274
        -- Ix stuff
        ixClassName,
275

276 277
        -- Show stuff
        showClassName,
278

279 280
        -- Read stuff
        readClassName,
281

282 283
        -- Stable pointers
        newStablePtrName,
284

285
        -- GHC Extensions
286
        groupWithName,
287

288 289 290
        -- Strings and lists
        unpackCStringName,
        unpackCStringFoldrName, unpackCStringUtf8Name,
291

292 293 294 295 296
        -- Overloaded lists
        isListClassName,
        fromListName,
        fromListNName,
        toListName,
297

298 299 300
        -- List operations
        concatName, filterName, mapName,
        zipName, foldrName, buildName, augmentName, appendName,
301

302 303 304
        -- FFI primitive types that are not wired-in.
        stablePtrTyConName, ptrTyConName, funPtrTyConName,
        int8TyConName, int16TyConName, int32TyConName, int64TyConName,
305
        word16TyConName, word32TyConName, word64TyConName,
306

307 308 309
        -- Others
        otherwiseIdName, inlineIdName,
        eqStringName, assertName, breakpointName, breakpointCondName,
310
        breakpointAutoName,  opaqueTyConName,
rwbarton's avatar
rwbarton committed
311
        assertErrorName,
312
        printName, fstName, sndName,
313

314
        -- Integer
315
        integerTyConName, mkIntegerName,
316
        integerToWord64Name, integerToInt64Name,
Ian Lynagh's avatar
Ian Lynagh committed
317
        word64ToIntegerName, int64ToIntegerName,
318
        plusIntegerName, timesIntegerName, smallIntegerName,
319
        wordToIntegerName,
320
        integerToWordName, integerToIntName, minusIntegerName,
321
        negateIntegerName, eqIntegerPrimName, neqIntegerPrimName,
322
        absIntegerName, signumIntegerName,
323
        leIntegerPrimName, gtIntegerPrimName, ltIntegerPrimName, geIntegerPrimName,
Ian Lynagh's avatar
Ian Lynagh committed
324
        compareIntegerName, quotRemIntegerName, divModIntegerName,
325
        quotIntegerName, remIntegerName, divIntegerName, modIntegerName,
326
        floatFromIntegerName, doubleFromIntegerName,
327
        encodeFloatIntegerName, encodeDoubleIntegerName,
Ian Lynagh's avatar
Ian Lynagh committed
328
        decodeDoubleIntegerName,
329 330
        gcdIntegerName, lcmIntegerName,
        andIntegerName, orIntegerName, xorIntegerName, complementIntegerName,
331
        shiftLIntegerName, shiftRIntegerName, bitIntegerName,
332

333 334 335 336
        -- Float/Double
        rationalToFloatName,
        rationalToDoubleName,

337 338
        -- Other classes
        randomClassName, randomGenClassName, monadPlusClassName,
339

340
        -- Type-level naturals
341
        knownNatClassName, knownSymbolClassName,
342

Adam Gundry's avatar
Adam Gundry committed
343 344 345
        -- Overloaded labels
        isLabelClassName,

346 347 348 349 350
        -- Implicit Parameters
        ipClassName,

        -- Call Stacks
        callStackTyConName,
Eric Seidel's avatar
Eric Seidel committed
351
        emptyCallStackName, pushCallStackName,
352 353

        -- Source Locations
354 355
        srcLocDataConName,

356
        -- Annotation type checking
357
        toAnnotationWrapperName
358

359
        -- The Ordering type
Ben Gamari's avatar
Ben Gamari committed
360 361
        , orderingTyConName
        , ltDataConName, eqDataConName, gtDataConName
362

363 364 365
        -- The SPEC type for SpecConstr
        , specTyConName

366 367
        -- The Either type
        , eitherTyConName, leftDataConName, rightDataConName
368

369 370
        -- Plugins
        , pluginTyConName
Edward Z. Yang's avatar
Edward Z. Yang committed
371
        , frontendPluginTyConName
372 373 374 375 376

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

377 378 379 380
        -- Monad comprehensions
        , guardMName
        , liftMName
        , mzipName
dterei's avatar
dterei committed
381 382 383

        -- GHCi Sandbox
        , ghciIoClassName, ghciStepIoMName
Facundo Domínguez's avatar
Facundo Domínguez committed
384 385

        -- StaticPtr
386
        , makeStaticName
Facundo Domínguez's avatar
Facundo Domínguez committed
387 388
        , staticPtrTyConName
        , staticPtrDataConName, staticPtrInfoDataConName
389
        , fromStaticPtrName
Facundo Domínguez's avatar
Facundo Domínguez committed
390 391 392 393

        -- Fingerprint
        , fingerprintDataConName

394 395 396 397 398 399 400
        -- Custom type errors
        , errorMessageTypeErrorFamName
        , typeErrorTextDataConName
        , typeErrorAppendDataConName
        , typeErrorVAppendDataConName
        , typeErrorShowTypeDataConName

401 402 403
        -- homogeneous equality
        , eqTyConName

404 405 406
    ] ++ case cIntegerLibraryType of
           IntegerGMP    -> [integerSDataConName]
           IntegerSimple -> []
407

408
genericTyConNames :: [Name]
409 410 411
genericTyConNames = [
    v1TyConName, u1TyConName, par1TyConName, rec1TyConName,
    k1TyConName, m1TyConName, sumTyConName, prodTyConName,
412 413
    compTyConName, rTyConName, dTyConName,
    cTyConName, sTyConName, rec0TyConName,
414
    d1TyConName, c1TyConName, s1TyConName, noSelTyConName,
415 416
    repTyConName, rep1TyConName, uRecTyConName,
    uAddrTyConName, uCharTyConName, uDoubleTyConName,
417 418 419
    uFloatTyConName, uIntTyConName, uWordTyConName,
    prefixIDataConName, infixIDataConName, leftAssociativeDataConName,
    rightAssociativeDataConName, notAssociativeDataConName,
420 421 422 423 424
    sourceUnpackDataConName, sourceNoUnpackDataConName,
    noSourceUnpackednessDataConName, sourceLazyDataConName,
    sourceStrictDataConName, noSourceStrictnessDataConName,
    decidedLazyDataConName, decidedStrictDataConName, decidedUnpackDataConName,
    metaDataDataConName, metaConsDataConName, metaSelDataConName
425
  ]
426

Austin Seipp's avatar
Austin Seipp committed
427 428 429
{-
************************************************************************
*                                                                      *
430
\subsection{Module names}
Austin Seipp's avatar
Austin Seipp committed
431 432
*                                                                      *
************************************************************************
433

434 435

--MetaHaskell Extension Add a new module here
Austin Seipp's avatar
Austin Seipp committed
436 437
-}

Ian Lynagh's avatar
Ian Lynagh committed
438
pRELUDE :: Module
439
pRELUDE         = mkBaseModule_ pRELUDE_NAME
Ian Lynagh's avatar
Ian Lynagh committed
440

Joachim Breitner's avatar
Joachim Breitner committed
441
gHC_PRIM, gHC_TYPES, gHC_GENERICS, gHC_MAGIC,
dterei's avatar
dterei committed
442
    gHC_CLASSES, gHC_BASE, gHC_ENUM, gHC_GHCI, gHC_CSTRING,
443
    gHC_SHOW, gHC_READ, gHC_NUM, gHC_INTEGER_TYPE, gHC_LIST,
444 445
    gHC_TUPLE, dATA_TUPLE, dATA_EITHER, dATA_STRING,
    dATA_FOLDABLE, dATA_TRAVERSABLE, dATA_MONOID, dATA_SEMIGROUP,
dterei's avatar
dterei committed
446 447
    gHC_CONC, gHC_IO, gHC_IO_Exception,
    gHC_ST, gHC_ARR, gHC_STABLE, gHC_PTR, gHC_ERR, gHC_REAL,
448
    gHC_FLOAT, gHC_TOP_HANDLER, sYSTEM_IO, dYNAMIC,
449
    tYPEABLE, tYPEABLE_INTERNAL, gENERICS,
quchen's avatar
quchen committed
450
    rEAD_PREC, lEX, gHC_INT, gHC_WORD, mONAD, mONAD_FIX, mONAD_ZIP, mONAD_FAIL,
451
    aRROW, cONTROL_APPLICATIVE, gHC_DESUGAR, rANDOM, gHC_EXTS,
452 453
    cONTROL_EXCEPTION_BASE, gHC_TYPELITS, dATA_TYPE_EQUALITY,
    dATA_COERCE :: Module
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
454

455
gHC_PRIM        = mkPrimModule (fsLit "GHC.Prim")   -- Primitive types and values
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
456
gHC_TYPES       = mkPrimModule (fsLit "GHC.Types")
457 458 459 460 461 462
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")
dterei's avatar
dterei committed
463
gHC_GHCI        = mkBaseModule (fsLit "GHC.GHCi")
464 465 466
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
467
gHC_INTEGER_TYPE= mkIntegerModule (fsLit "GHC.Integer.Type")
468 469 470
gHC_LIST        = mkBaseModule (fsLit "GHC.List")
gHC_TUPLE       = mkPrimModule (fsLit "GHC.Tuple")
dATA_TUPLE      = mkBaseModule (fsLit "Data.Tuple")
471 472 473
dATA_EITHER     = mkBaseModule (fsLit "Data.Either")
dATA_STRING     = mkBaseModule (fsLit "Data.String")
dATA_FOLDABLE   = mkBaseModule (fsLit "Data.Foldable")
474
dATA_TRAVERSABLE= mkBaseModule (fsLit "Data.Traversable")
475
dATA_SEMIGROUP  = mkBaseModule (fsLit "Data.Semigroup")
476
dATA_MONOID     = mkBaseModule (fsLit "Data.Monoid")
477 478
gHC_CONC        = mkBaseModule (fsLit "GHC.Conc")
gHC_IO          = mkBaseModule (fsLit "GHC.IO")
479
gHC_IO_Exception = mkBaseModule (fsLit "GHC.IO.Exception")
480 481 482 483 484 485 486 487 488 489
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")
490 491
tYPEABLE        = mkBaseModule (fsLit "Data.Typeable")
tYPEABLE_INTERNAL = mkBaseModule (fsLit "Data.Typeable.Internal")
492
gENERICS        = mkBaseModule (fsLit "Data.Data")
493 494 495 496 497 498
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")
499
mONAD_ZIP       = mkBaseModule (fsLit "Control.Monad.Zip")
quchen's avatar
quchen committed
500
mONAD_FAIL      = mkBaseModule (fsLit "Control.Monad.Fail")
501
aRROW           = mkBaseModule (fsLit "Control.Arrow")
502
cONTROL_APPLICATIVE = mkBaseModule (fsLit "Control.Applicative")
Ian Lynagh's avatar
Ian Lynagh committed
503
gHC_DESUGAR = mkBaseModule (fsLit "GHC.Desugar")
504 505
rANDOM          = mkBaseModule (fsLit "System.Random")
gHC_EXTS        = mkBaseModule (fsLit "GHC.Exts")
506
cONTROL_EXCEPTION_BASE = mkBaseModule (fsLit "Control.Exception.Base")
jpm@cs.ox.ac.uk's avatar
jpm@cs.ox.ac.uk committed
507
gHC_GENERICS    = mkBaseModule (fsLit "GHC.Generics")
508
gHC_TYPELITS    = mkBaseModule (fsLit "GHC.TypeLits")
509 510
dATA_TYPE_EQUALITY = mkBaseModule (fsLit "Data.Type.Equality")
dATA_COERCE     = mkBaseModule (fsLit "Data.Coerce")
Simon Marlow's avatar
Simon Marlow committed
511

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

515 516 517
gHC_SRCLOC :: Module
gHC_SRCLOC = mkBaseModule (fsLit "GHC.SrcLoc")

Ben Gamari's avatar
Ben Gamari committed
518
gHC_STACK, gHC_STACK_TYPES :: Module
519
gHC_STACK = mkBaseModule (fsLit "GHC.Stack")
Ben Gamari's avatar
Ben Gamari committed
520
gHC_STACK_TYPES = mkBaseModule (fsLit "GHC.Stack.Types")
521

Facundo Domínguez's avatar
Facundo Domínguez committed
522 523 524
gHC_STATICPTR :: Module
gHC_STATICPTR = mkBaseModule (fsLit "GHC.StaticPtr")

525 526 527
gHC_STATICPTR_INTERNAL :: Module
gHC_STATICPTR_INTERNAL = mkBaseModule (fsLit "GHC.StaticPtr.Internal")

Facundo Domínguez's avatar
Facundo Domínguez committed
528 529 530
gHC_FINGERPRINT_TYPE :: Module
gHC_FINGERPRINT_TYPE = mkBaseModule (fsLit "GHC.Fingerprint.Type")

Adam Gundry's avatar
Adam Gundry committed
531 532 533
gHC_OVER_LABELS :: Module
gHC_OVER_LABELS = mkBaseModule (fsLit "GHC.OverloadedLabels")

Ian Lynagh's avatar
Ian Lynagh committed
534
mAIN, rOOT_MAIN :: Module
535 536
mAIN            = mkMainModule_ mAIN_NAME
rOOT_MAIN       = mkMainModule (fsLit ":Main") -- Root module for initialisation
Simon Marlow's avatar
Simon Marlow committed
537

538 539
mkInteractiveModule :: Int -> Module
-- (mkInteractiveMoudule 9) makes module 'interactive:M9'
540
mkInteractiveModule n = mkModule interactiveUnitId (mkModuleName ("Ghci" ++ show n))
Simon Marlow's avatar
Simon Marlow committed
541

Ian Lynagh's avatar
Ian Lynagh committed
542
pRELUDE_NAME, mAIN_NAME :: ModuleName
Ian Lynagh's avatar
Ian Lynagh committed
543 544
pRELUDE_NAME   = mkModuleNameFS (fsLit "Prelude")
mAIN_NAME      = mkModuleNameFS (fsLit "Main")
Simon Marlow's avatar
Simon Marlow committed
545

546 547 548 549
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
550
mkPrimModule :: FastString -> Module
551
mkPrimModule m = mkModule primUnitId (mkModuleNameFS m)
Ian Lynagh's avatar
Ian Lynagh committed
552 553

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

Simon Marlow's avatar
Simon Marlow committed
556
mkBaseModule :: FastString -> Module
557
mkBaseModule m = mkModule baseUnitId (mkModuleNameFS m)
Simon Marlow's avatar
Simon Marlow committed
558 559

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

562
mkThisGhcModule :: FastString -> Module
563
mkThisGhcModule m = mkModule thisGhcUnitId (mkModuleNameFS m)
564 565

mkThisGhcModule_ :: ModuleName -> Module
566
mkThisGhcModule_ m = mkModule thisGhcUnitId m
567

Simon Marlow's avatar
Simon Marlow committed
568
mkMainModule :: FastString -> Module
569
mkMainModule m = mkModule mainUnitId (mkModuleNameFS m)
570

Simon Marlow's avatar
Simon Marlow committed
571
mkMainModule_ :: ModuleName -> Module
572
mkMainModule_ m = mkModule mainUnitId m
573

Austin Seipp's avatar
Austin Seipp committed
574 575 576
{-
************************************************************************
*                                                                      *
577
                        RdrNames
Austin Seipp's avatar
Austin Seipp committed
578 579 580
*                                                                      *
************************************************************************
-}
581

Ian Lynagh's avatar
Ian Lynagh committed
582
main_RDR_Unqual    :: RdrName
583 584 585
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
586

587
forall_tv_RDR, dot_tv_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
588 589
forall_tv_RDR = mkUnqual tvName (fsLit "forall")
dot_tv_RDR    = mkUnqual tvName (fsLit ".")
590

Ian Lynagh's avatar
Ian Lynagh committed
591 592
eq_RDR, ge_RDR, ne_RDR, le_RDR, lt_RDR, gt_RDR, compare_RDR,
    ltTag_RDR, eqTag_RDR, gtTag_RDR :: RdrName
593 594 595 596 597 598 599
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
600 601 602
ltTag_RDR               = dataQual_RDR gHC_TYPES (fsLit "LT")
eqTag_RDR               = dataQual_RDR gHC_TYPES (fsLit "EQ")
gtTag_RDR               = dataQual_RDR gHC_TYPES (fsLit "GT")
603

Ian Lynagh's avatar
Ian Lynagh committed
604 605
eqClass_RDR, numClass_RDR, ordClass_RDR, enumClass_RDR, monadClass_RDR
    :: RdrName
606 607 608 609 610
eqClass_RDR             = nameRdrName eqClassName
numClass_RDR            = nameRdrName numClassName
ordClass_RDR            = nameRdrName ordClassName
enumClass_RDR           = nameRdrName enumClassName
monadClass_RDR          = nameRdrName monadClassName
611

Ian Lynagh's avatar
Ian Lynagh committed
612
map_RDR, append_RDR :: RdrName
613 614
map_RDR                 = varQual_RDR gHC_BASE (fsLit "map")
append_RDR              = varQual_RDR gHC_BASE (fsLit "++")
615

quchen's avatar
quchen committed
616
foldr_RDR, build_RDR, returnM_RDR, bindM_RDR, failM_RDR_preMFP, failM_RDR:: RdrName
617 618 619 620
foldr_RDR               = nameRdrName foldrName
build_RDR               = nameRdrName buildName
returnM_RDR             = nameRdrName returnMName
bindM_RDR               = nameRdrName bindMName
quchen's avatar
quchen committed
621
failM_RDR_preMFP        = nameRdrName failMName_preMFP
622
failM_RDR               = nameRdrName failMName
623

Ian Lynagh's avatar
Ian Lynagh committed
624
left_RDR, right_RDR :: RdrName
625 626
left_RDR                = nameRdrName leftDataConName
right_RDR               = nameRdrName rightDataConName
627

Ian Lynagh's avatar
Ian Lynagh committed
628
fromEnum_RDR, toEnum_RDR :: RdrName
629 630
fromEnum_RDR            = varQual_RDR gHC_ENUM (fsLit "fromEnum")
toEnum_RDR              = varQual_RDR gHC_ENUM (fsLit "toEnum")
631

Ian Lynagh's avatar
Ian Lynagh committed
632
enumFrom_RDR, enumFromTo_RDR, enumFromThen_RDR, enumFromThenTo_RDR :: RdrName
633 634 635 636
enumFrom_RDR            = nameRdrName enumFromName
enumFromTo_RDR          = nameRdrName enumFromToName
enumFromThen_RDR        = nameRdrName enumFromThenName
enumFromThenTo_RDR      = nameRdrName enumFromThenToName
637

Ian Lynagh's avatar
Ian Lynagh committed
638
ratioDataCon_RDR, plusInteger_RDR, timesInteger_RDR :: RdrName
639 640 641
ratioDataCon_RDR        = nameRdrName ratioDataConName
plusInteger_RDR         = nameRdrName plusIntegerName
timesInteger_RDR        = nameRdrName timesIntegerName
642

Ian Lynagh's avatar
Ian Lynagh committed
643
ioDataCon_RDR :: RdrName
644
ioDataCon_RDR           = nameRdrName ioDataConName
645

Ian Lynagh's avatar
Ian Lynagh committed
646 647
eqString_RDR, unpackCString_RDR, unpackCStringFoldr_RDR,
    unpackCStringUtf8_RDR :: RdrName
648 649 650 651
eqString_RDR            = nameRdrName eqStringName
unpackCString_RDR       = nameRdrName unpackCStringName
unpackCStringFoldr_RDR  = nameRdrName unpackCStringFoldrName
unpackCStringUtf8_RDR   = nameRdrName unpackCStringUtf8Name
652

653
newStablePtr_RDR :: RdrName
654
newStablePtr_RDR        = nameRdrName newStablePtrName
655

Ian Lynagh's avatar
Ian Lynagh committed
656
bindIO_RDR, returnIO_RDR :: RdrName
657 658
bindIO_RDR              = nameRdrName bindIOName
returnIO_RDR            = nameRdrName returnIOName
659

Ian Lynagh's avatar
Ian Lynagh committed
660
fromInteger_RDR, fromRational_RDR, minus_RDR, times_RDR, plus_RDR :: RdrName
661 662 663 664
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
665
plus_RDR                = varQual_RDR gHC_NUM (fsLit "+")
Simon Marlow's avatar
Simon Marlow committed
666

Ryan Scott's avatar
Ryan Scott committed
667 668 669 670 671
toInteger_RDR, toRational_RDR, fromIntegral_RDR :: RdrName
toInteger_RDR           = nameRdrName toIntegerName
toRational_RDR          = nameRdrName toRationalName
fromIntegral_RDR        = nameRdrName fromIntegralName

672 673
stringTy_RDR, fromString_RDR :: RdrName
stringTy_RDR            = tcQual_RDR gHC_BASE (fsLit "String")
674
fromString_RDR          = nameRdrName fromStringName
675

676 677 678 679 680
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
681
compose_RDR :: RdrName
682
compose_RDR             = varQual_RDR gHC_BASE (fsLit ".")
Simon Marlow's avatar
Simon Marlow committed
683

Ian Lynagh's avatar
Ian Lynagh committed
684
not_RDR, getTag_RDR, succ_RDR, pred_RDR, minBound_RDR, maxBound_RDR,
685
    and_RDR, range_RDR, inRange_RDR, index_RDR,
Ian Lynagh's avatar
Ian Lynagh committed
686
    unsafeIndex_RDR, unsafeRangeSize_RDR :: RdrName
687 688 689 690
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
691 692 693 694 695
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")
696 697 698
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
699

Ian Lynagh's avatar
Ian Lynagh committed
700
readList_RDR, readListDefault_RDR, readListPrec_RDR, readListPrecDefault_RDR,
701
    readPrec_RDR, parens_RDR, choose_RDR, lexP_RDR, expectP_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
702 703 704 705 706 707 708 709
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")
710
expectP_RDR             = varQual_RDR gHC_READ (fsLit "expectP")
711

Ian Lynagh's avatar
Ian Lynagh committed
712
punc_RDR, ident_RDR, symbol_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
713 714 715
punc_RDR                = dataQual_RDR lEX (fsLit "Punc")
ident_RDR               = dataQual_RDR lEX (fsLit "Ident")
symbol_RDR              = dataQual_RDR lEX (fsLit "Symbol")
716

717
step_RDR, alt_RDR, reset_RDR, prec_RDR, pfail_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
718
step_RDR                = varQual_RDR  rEAD_PREC (fsLit "step")
719
alt_RDR                 = varQual_RDR  rEAD_PREC (fsLit "+++")
Ian Lynagh's avatar
Ian Lynagh committed
720 721
reset_RDR               = varQual_RDR  rEAD_PREC (fsLit "reset")
prec_RDR                = varQual_RDR  rEAD_PREC (fsLit "prec")
722
pfail_RDR               = varQual_RDR  rEAD_PREC (fsLit "pfail")
723

thomie's avatar
thomie committed
724
showList_RDR, showList___RDR, showsPrec_RDR, shows_RDR, showString_RDR,
Ian Lynagh's avatar
Ian Lynagh committed
725
    showSpace_RDR, showParen_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
726 727
showList_RDR            = varQual_RDR gHC_SHOW (fsLit "showList")
showList___RDR          = varQual_RDR gHC_SHOW (fsLit "showList__")
728
showsPrec_RDR           = varQual_RDR gHC_SHOW (fsLit "showsPrec")
thomie's avatar
thomie committed
729
shows_RDR               = varQual_RDR gHC_SHOW (fsLit "shows")
Ian Lynagh's avatar
Ian Lynagh committed
730
showString_RDR          = varQual_RDR gHC_SHOW (fsLit "showString")
731 732
showSpace_RDR           = varQual_RDR gHC_SHOW (fsLit "showSpace")
showParen_RDR           = varQual_RDR gHC_SHOW (fsLit "showParen")
733

Ian Lynagh's avatar
Ian Lynagh committed
734
undefined_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
735
undefined_RDR = varQual_RDR gHC_ERR (fsLit "undefined")
736

737 738 739 740 741 742
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
743 744 745
  prodDataCon_RDR, comp1DataCon_RDR,
  unPar1_RDR, unRec1_RDR, unK1_RDR, unComp1_RDR,
  from_RDR, from1_RDR, to_RDR, to1_RDR,
746
  datatypeName_RDR, moduleName_RDR, packageName_RDR, isNewtypeName_RDR,
747
  conName_RDR, conFixity_RDR, conIsRecord_RDR, selName_RDR,
748
  prefixDataCon_RDR, infixDataCon_RDR, leftAssocDataCon_RDR,
749 750 751 752 753
  rightAssocDataCon_RDR, notAssocDataCon_RDR,
  uAddrDataCon_RDR, uCharDataCon_RDR, uDoubleDataCon_RDR,
  uFloatDataCon_RDR, uIntDataCon_RDR, uWordDataCon_RDR,
  uAddrHash_RDR, uCharHash_RDR, uDoubleHash_RDR,
  uFloatHash_RDR, uIntHash_RDR, uWordHash_RDR :: RdrName
754 755 756 757 758 759 760 761 762 763 764 765 766

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

jpm@cs.ox.ac.uk's avatar
jpm@cs.ox.ac.uk committed
767 768 769 770 771
unPar1_RDR  = varQual_RDR gHC_GENERICS (fsLit "unPar1")
unRec1_RDR  = varQual_RDR gHC_GENERICS (fsLit "unRec1")
unK1_RDR    = varQual_RDR gHC_GENERICS (fsLit "unK1")
unComp1_RDR = varQual_RDR gHC_GENERICS (fsLit "unComp1")

772
from_RDR  = varQual_RDR gHC_GENERICS (fsLit "from")
773
from1_RDR = varQual_RDR gHC_GENERICS (fsLit "from1")
774
to_RDR    = varQual_RDR gHC_GENERICS (fsLit "to")
775 776 777 778
to1_RDR   = varQual_RDR gHC_GENERICS (fsLit "to1")

datatypeName_RDR  = varQual_RDR gHC_GENERICS (fsLit "datatypeName")
moduleName_RDR    = varQual_RDR gHC_GENERICS (fsLit "moduleName")
779
packageName_RDR   = varQual_RDR gHC_GENERICS (fsLit "packageName")
780
isNewtypeName_RDR = varQual_RDR gHC_GENERICS (fsLit "isNewtype")
781 782 783 784 785 786 787 788 789 790 791
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")

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

792 793 794 795 796 797 798 799 800 801 802 803 804
uAddrDataCon_RDR   = dataQual_RDR gHC_GENERICS (fsLit "UAddr")
uCharDataCon_RDR   = dataQual_RDR gHC_GENERICS (fsLit "UChar")
uDoubleDataCon_RDR = dataQual_RDR gHC_GENERICS (fsLit "UDouble")
uFloatDataCon_RDR  = dataQual_RDR gHC_GENERICS (fsLit "UFloat")
uIntDataCon_RDR    = dataQual_RDR gHC_GENERICS (fsLit "UInt")
uWordDataCon_RDR   = dataQual_RDR gHC_GENERICS (fsLit "UWord")

uAddrHash_RDR   = varQual_RDR gHC_GENERICS (fsLit "uAddr#")
uCharHash_RDR   = varQual_RDR gHC_GENERICS (fsLit "uChar#")
uDoubleHash_RDR = varQual_RDR gHC_GENERICS (fsLit "uDouble#")
uFloatHash_RDR  = varQual_RDR gHC_GENERICS (fsLit "uFloat#")
uIntHash_RDR    = varQual_RDR gHC_GENERICS (fsLit "uInt#")
uWordHash_RDR   = varQual_RDR gHC_GENERICS (fsLit "uWord#")
805

806 807
fmap_RDR, pure_RDR, ap_RDR, foldable_foldr_RDR, foldMap_RDR,
    traverse_RDR, mempty_RDR, mappend_RDR :: RdrName
808
fmap_RDR                = varQual_RDR gHC_BASE (fsLit "fmap")
809 810
pure_RDR                = nameRdrName pureAName
ap_RDR                  = nameRdrName apAName
811
foldable_foldr_RDR      = varQual_RDR dATA_FOLDABLE       (fsLit "foldr")
812
foldMap_RDR             = varQual_RDR dATA_FOLDABLE       (fsLit "foldMap")
813
traverse_RDR            = varQual_RDR dATA_TRAVERSABLE    (fsLit "traverse")
Austin Seipp's avatar