PrelNames.hs 106 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,
Ben Gamari's avatar
Ben Gamari committed
227 228 229 230 231 232 233 234 235 236 237 238 239
        someTypeRepTyConName,
        someTypeRepDataConName,
        kindRepTyConName,
        kindRepTyConAppDataConName,
        kindRepVarDataConName,
        kindRepAppDataConName,
        kindRepFunDataConName,
        kindRepTYPEDataConName,
        kindRepTypeLitSDataConName,
        kindRepTypeLitDDataConName,
        typeLitSortTyConName,
        typeLitSymbolDataConName,
        typeLitNatDataConName,
240
        typeRepIdName,
Ben Gamari's avatar
Ben Gamari committed
241 242 243
        mkTrConName,
        mkTrAppName,
        mkTrFunName,
244
        typeSymbolTypeRepName, typeNatTypeRepName,
245
        trGhcPrimModuleName,
246

247 248 249 250 251
        -- KindReps for common cases
        starKindRepName,
        starArrStarKindRepName,
        starArrStarArrStarKindRepName,

252 253
        -- Dynamic
        toDynName,
254 255

        -- Numeric stuff
256 257 258
        negateName, minusName, geName, eqName,

        -- Conversion functions
Ben Gamari's avatar
Ben Gamari committed
259 260
        rationalTyConName,
        ratioTyConName, ratioDataConName,
261 262 263
        fromRationalName, fromIntegerName,
        toIntegerName, toRationalName,
        fromIntegralName, realToFracName,
264

265 266 267
        -- Int# stuff
        divIntName, modIntName,

268 269
        -- String stuff
        fromStringName,
270 271 272 273 274

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

275 276
        -- Applicative stuff
        pureAName, apAName, thenAName,
277

David Feuer's avatar
David Feuer committed
278 279 280
        -- Functor stuff
        fmapName,

281
        -- Monad stuff
quchen's avatar
quchen committed
282
        thenIOName, bindIOName, returnIOName, failIOName, bindMName, thenMName,
David Feuer's avatar
David Feuer committed
283
        returnMName, joinMName,
quchen's avatar
quchen committed
284 285 286

        -- MonadFail
        monadFailClassName, failMName, failMName_preMFP,
287

288 289
        -- MonadFix
        monadFixClassName, mfixName,
290

291 292 293
        -- Arrow stuff
        arrAName, composeAName, firstAName,
        appAName, choiceAName, loopAName,
294

295 296
        -- Ix stuff
        ixClassName,
297

298 299
        -- Show stuff
        showClassName,
300

301 302
        -- Read stuff
        readClassName,
303

304 305
        -- Stable pointers
        newStablePtrName,
306

307
        -- GHC Extensions
308
        groupWithName,
309

310 311 312
        -- Strings and lists
        unpackCStringName,
        unpackCStringFoldrName, unpackCStringUtf8Name,
313

314 315 316 317 318
        -- Overloaded lists
        isListClassName,
        fromListName,
        fromListNName,
        toListName,
319

320 321 322
        -- List operations
        concatName, filterName, mapName,
        zipName, foldrName, buildName, augmentName, appendName,
323

324 325 326
        -- FFI primitive types that are not wired-in.
        stablePtrTyConName, ptrTyConName, funPtrTyConName,
        int8TyConName, int16TyConName, int32TyConName, int64TyConName,
327
        word16TyConName, word32TyConName, word64TyConName,
328

329 330 331
        -- Others
        otherwiseIdName, inlineIdName,
        eqStringName, assertName, breakpointName, breakpointCondName,
332
        breakpointAutoName,  opaqueTyConName,
rwbarton's avatar
rwbarton committed
333
        assertErrorName,
334
        printName, fstName, sndName,
335

336
        -- Integer
337
        integerTyConName, mkIntegerName,
338
        integerToWord64Name, integerToInt64Name,
Ian Lynagh's avatar
Ian Lynagh committed
339
        word64ToIntegerName, int64ToIntegerName,
340
        plusIntegerName, timesIntegerName, smallIntegerName,
341
        wordToIntegerName,
342
        integerToWordName, integerToIntName, minusIntegerName,
343
        negateIntegerName, eqIntegerPrimName, neqIntegerPrimName,
344
        absIntegerName, signumIntegerName,
345
        leIntegerPrimName, gtIntegerPrimName, ltIntegerPrimName, geIntegerPrimName,
Ian Lynagh's avatar
Ian Lynagh committed
346
        compareIntegerName, quotRemIntegerName, divModIntegerName,
347
        quotIntegerName, remIntegerName, divIntegerName, modIntegerName,
348
        floatFromIntegerName, doubleFromIntegerName,
349
        encodeFloatIntegerName, encodeDoubleIntegerName,
Ian Lynagh's avatar
Ian Lynagh committed
350
        decodeDoubleIntegerName,
351 352
        gcdIntegerName, lcmIntegerName,
        andIntegerName, orIntegerName, xorIntegerName, complementIntegerName,
353
        shiftLIntegerName, shiftRIntegerName, bitIntegerName,
354

355 356 357 358
        -- Natural
        naturalTyConName,
        naturalFromIntegerName,

359 360 361 362
        -- Float/Double
        rationalToFloatName,
        rationalToDoubleName,

363 364
        -- Other classes
        randomClassName, randomGenClassName, monadPlusClassName,
365

366
        -- Type-level naturals
367
        knownNatClassName, knownSymbolClassName,
368

Adam Gundry's avatar
Adam Gundry committed
369 370 371
        -- Overloaded labels
        isLabelClassName,

372 373 374
        -- Implicit Parameters
        ipClassName,

375 376 377
        -- Overloaded record fields
        hasFieldClassName,

378 379
        -- Call Stacks
        callStackTyConName,
Eric Seidel's avatar
Eric Seidel committed
380
        emptyCallStackName, pushCallStackName,
381 382

        -- Source Locations
383 384
        srcLocDataConName,

385
        -- Annotation type checking
386
        toAnnotationWrapperName
387

388
        -- The Ordering type
Ben Gamari's avatar
Ben Gamari committed
389 390
        , orderingTyConName
        , ltDataConName, eqDataConName, gtDataConName
391

392 393 394
        -- The SPEC type for SpecConstr
        , specTyConName

395 396
        -- The Either type
        , eitherTyConName, leftDataConName, rightDataConName
397

398 399
        -- Plugins
        , pluginTyConName
Edward Z. Yang's avatar
Edward Z. Yang committed
400
        , frontendPluginTyConName
401 402 403 404 405

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

406 407 408 409
        -- Monad comprehensions
        , guardMName
        , liftMName
        , mzipName
dterei's avatar
dterei committed
410 411 412

        -- GHCi Sandbox
        , ghciIoClassName, ghciStepIoMName
413 414

        -- StaticPtr
415
        , makeStaticName
416 417
        , staticPtrTyConName
        , staticPtrDataConName, staticPtrInfoDataConName
418
        , fromStaticPtrName
419 420 421 422

        -- Fingerprint
        , fingerprintDataConName

423 424 425 426 427 428 429
        -- Custom type errors
        , errorMessageTypeErrorFamName
        , typeErrorTextDataConName
        , typeErrorAppendDataConName
        , typeErrorVAppendDataConName
        , typeErrorShowTypeDataConName

430 431 432
        -- homogeneous equality
        , eqTyConName

433 434 435
    ] ++ case cIntegerLibraryType of
           IntegerGMP    -> [integerSDataConName]
           IntegerSimple -> []
436

437
genericTyConNames :: [Name]
438 439 440
genericTyConNames = [
    v1TyConName, u1TyConName, par1TyConName, rec1TyConName,
    k1TyConName, m1TyConName, sumTyConName, prodTyConName,
441 442
    compTyConName, rTyConName, dTyConName,
    cTyConName, sTyConName, rec0TyConName,
443
    d1TyConName, c1TyConName, s1TyConName, noSelTyConName,
444 445
    repTyConName, rep1TyConName, uRecTyConName,
    uAddrTyConName, uCharTyConName, uDoubleTyConName,
446 447 448
    uFloatTyConName, uIntTyConName, uWordTyConName,
    prefixIDataConName, infixIDataConName, leftAssociativeDataConName,
    rightAssociativeDataConName, notAssociativeDataConName,
449 450 451 452 453
    sourceUnpackDataConName, sourceNoUnpackDataConName,
    noSourceUnpackednessDataConName, sourceLazyDataConName,
    sourceStrictDataConName, noSourceStrictnessDataConName,
    decidedLazyDataConName, decidedStrictDataConName, decidedUnpackDataConName,
    metaDataDataConName, metaConsDataConName, metaSelDataConName
454
  ]
455

Austin Seipp's avatar
Austin Seipp committed
456 457 458
{-
************************************************************************
*                                                                      *
459
\subsection{Module names}
Austin Seipp's avatar
Austin Seipp committed
460 461
*                                                                      *
************************************************************************
462

463 464

--MetaHaskell Extension Add a new module here
Austin Seipp's avatar
Austin Seipp committed
465 466
-}

Ian Lynagh's avatar
Ian Lynagh committed
467
pRELUDE :: Module
468
pRELUDE         = mkBaseModule_ pRELUDE_NAME
Ian Lynagh's avatar
Ian Lynagh committed
469

470
gHC_PRIM, gHC_TYPES, gHC_GENERICS, gHC_MAGIC,
dterei's avatar
dterei committed
471
    gHC_CLASSES, gHC_BASE, gHC_ENUM, gHC_GHCI, gHC_CSTRING,
472
    gHC_SHOW, gHC_READ, gHC_NUM, gHC_INTEGER_TYPE, gHC_NATURAL, gHC_LIST,
473
    gHC_TUPLE, dATA_TUPLE, dATA_EITHER, dATA_STRING,
474
    dATA_FOLDABLE, dATA_TRAVERSABLE,
dterei's avatar
dterei committed
475 476
    gHC_CONC, gHC_IO, gHC_IO_Exception,
    gHC_ST, gHC_ARR, gHC_STABLE, gHC_PTR, gHC_ERR, gHC_REAL,
477
    gHC_FLOAT, gHC_TOP_HANDLER, sYSTEM_IO, dYNAMIC,
478
    tYPEABLE, tYPEABLE_INTERNAL, gENERICS,
quchen's avatar
quchen committed
479
    rEAD_PREC, lEX, gHC_INT, gHC_WORD, mONAD, mONAD_FIX, mONAD_ZIP, mONAD_FAIL,
480
    aRROW, cONTROL_APPLICATIVE, gHC_DESUGAR, rANDOM, gHC_EXTS,
481
    cONTROL_EXCEPTION_BASE, gHC_TYPELITS, gHC_TYPENATS, dATA_TYPE_EQUALITY,
482
    dATA_COERCE :: Module
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
483

484
gHC_PRIM        = mkPrimModule (fsLit "GHC.Prim")   -- Primitive types and values
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
485
gHC_TYPES       = mkPrimModule (fsLit "GHC.Types")
486 487 488 489 490 491
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
492
gHC_GHCI        = mkBaseModule (fsLit "GHC.GHCi")
493 494 495
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
496
gHC_INTEGER_TYPE= mkIntegerModule (fsLit "GHC.Integer.Type")
497
gHC_NATURAL     = mkBaseModule (fsLit "GHC.Natural")
498 499 500
gHC_LIST        = mkBaseModule (fsLit "GHC.List")
gHC_TUPLE       = mkPrimModule (fsLit "GHC.Tuple")
dATA_TUPLE      = mkBaseModule (fsLit "Data.Tuple")
501 502 503
dATA_EITHER     = mkBaseModule (fsLit "Data.Either")
dATA_STRING     = mkBaseModule (fsLit "Data.String")
dATA_FOLDABLE   = mkBaseModule (fsLit "Data.Foldable")
504
dATA_TRAVERSABLE= mkBaseModule (fsLit "Data.Traversable")
505 506
gHC_CONC        = mkBaseModule (fsLit "GHC.Conc")
gHC_IO          = mkBaseModule (fsLit "GHC.IO")
507
gHC_IO_Exception = mkBaseModule (fsLit "GHC.IO.Exception")
508 509 510 511 512 513 514 515 516 517
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")
518 519
tYPEABLE        = mkBaseModule (fsLit "Data.Typeable")
tYPEABLE_INTERNAL = mkBaseModule (fsLit "Data.Typeable.Internal")
520
gENERICS        = mkBaseModule (fsLit "Data.Data")
521 522 523 524 525 526
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")
527
mONAD_ZIP       = mkBaseModule (fsLit "Control.Monad.Zip")
quchen's avatar
quchen committed
528
mONAD_FAIL      = mkBaseModule (fsLit "Control.Monad.Fail")
529
aRROW           = mkBaseModule (fsLit "Control.Arrow")
530
cONTROL_APPLICATIVE = mkBaseModule (fsLit "Control.Applicative")
Ian Lynagh's avatar
Ian Lynagh committed
531
gHC_DESUGAR = mkBaseModule (fsLit "GHC.Desugar")
532 533
rANDOM          = mkBaseModule (fsLit "System.Random")
gHC_EXTS        = mkBaseModule (fsLit "GHC.Exts")
534
cONTROL_EXCEPTION_BASE = mkBaseModule (fsLit "Control.Exception.Base")
jpm@cs.ox.ac.uk's avatar
jpm@cs.ox.ac.uk committed
535
gHC_GENERICS    = mkBaseModule (fsLit "GHC.Generics")
536
gHC_TYPELITS    = mkBaseModule (fsLit "GHC.TypeLits")
537
gHC_TYPENATS    = mkBaseModule (fsLit "GHC.TypeNats")
538 539
dATA_TYPE_EQUALITY = mkBaseModule (fsLit "Data.Type.Equality")
dATA_COERCE     = mkBaseModule (fsLit "Data.Coerce")
Simon Marlow's avatar
Simon Marlow committed
540

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

544 545 546
gHC_SRCLOC :: Module
gHC_SRCLOC = mkBaseModule (fsLit "GHC.SrcLoc")

Ben Gamari's avatar
Ben Gamari committed
547
gHC_STACK, gHC_STACK_TYPES :: Module
548
gHC_STACK = mkBaseModule (fsLit "GHC.Stack")
Ben Gamari's avatar
Ben Gamari committed
549
gHC_STACK_TYPES = mkBaseModule (fsLit "GHC.Stack.Types")
550

551 552 553
gHC_STATICPTR :: Module
gHC_STATICPTR = mkBaseModule (fsLit "GHC.StaticPtr")

554 555 556
gHC_STATICPTR_INTERNAL :: Module
gHC_STATICPTR_INTERNAL = mkBaseModule (fsLit "GHC.StaticPtr.Internal")

557 558 559
gHC_FINGERPRINT_TYPE :: Module
gHC_FINGERPRINT_TYPE = mkBaseModule (fsLit "GHC.Fingerprint.Type")

Adam Gundry's avatar
Adam Gundry committed
560 561 562
gHC_OVER_LABELS :: Module
gHC_OVER_LABELS = mkBaseModule (fsLit "GHC.OverloadedLabels")

563 564 565
gHC_RECORDS :: Module
gHC_RECORDS = mkBaseModule (fsLit "GHC.Records")

Ian Lynagh's avatar
Ian Lynagh committed
566
mAIN, rOOT_MAIN :: Module
567 568
mAIN            = mkMainModule_ mAIN_NAME
rOOT_MAIN       = mkMainModule (fsLit ":Main") -- Root module for initialisation
Simon Marlow's avatar
Simon Marlow committed
569

570 571
mkInteractiveModule :: Int -> Module
-- (mkInteractiveMoudule 9) makes module 'interactive:M9'
572
mkInteractiveModule n = mkModule interactiveUnitId (mkModuleName ("Ghci" ++ show n))
Simon Marlow's avatar
Simon Marlow committed
573

Ian Lynagh's avatar
Ian Lynagh committed
574
pRELUDE_NAME, mAIN_NAME :: ModuleName
Ian Lynagh's avatar
Ian Lynagh committed
575 576
pRELUDE_NAME   = mkModuleNameFS (fsLit "Prelude")
mAIN_NAME      = mkModuleNameFS (fsLit "Main")
Simon Marlow's avatar
Simon Marlow committed
577

578 579 580 581
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
582
mkPrimModule :: FastString -> Module
583
mkPrimModule m = mkModule primUnitId (mkModuleNameFS m)
Ian Lynagh's avatar
Ian Lynagh committed
584 585

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

Simon Marlow's avatar
Simon Marlow committed
588
mkBaseModule :: FastString -> Module
589
mkBaseModule m = mkModule baseUnitId (mkModuleNameFS m)
Simon Marlow's avatar
Simon Marlow committed
590 591

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

594
mkThisGhcModule :: FastString -> Module
595
mkThisGhcModule m = mkModule thisGhcUnitId (mkModuleNameFS m)
596 597

mkThisGhcModule_ :: ModuleName -> Module
598
mkThisGhcModule_ m = mkModule thisGhcUnitId m
599

Simon Marlow's avatar
Simon Marlow committed
600
mkMainModule :: FastString -> Module
601
mkMainModule m = mkModule mainUnitId (mkModuleNameFS m)
602

Simon Marlow's avatar
Simon Marlow committed
603
mkMainModule_ :: ModuleName -> Module
604
mkMainModule_ m = mkModule mainUnitId m
605

Austin Seipp's avatar
Austin Seipp committed
606 607 608
{-
************************************************************************
*                                                                      *
609
                        RdrNames
Austin Seipp's avatar
Austin Seipp committed
610 611 612
*                                                                      *
************************************************************************
-}
613

Ian Lynagh's avatar
Ian Lynagh committed
614
main_RDR_Unqual    :: RdrName
615 616 617
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
618

619
forall_tv_RDR, dot_tv_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
620 621
forall_tv_RDR = mkUnqual tvName (fsLit "forall")
dot_tv_RDR    = mkUnqual tvName (fsLit ".")
622

David Feuer's avatar
David Feuer committed
623
eq_RDR, ge_RDR, le_RDR, lt_RDR, gt_RDR, compare_RDR,
Ian Lynagh's avatar
Ian Lynagh committed
624
    ltTag_RDR, eqTag_RDR, gtTag_RDR :: RdrName
625 626 627 628 629 630
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")
Ian Lynagh's avatar
Ian Lynagh committed
631 632 633
ltTag_RDR               = dataQual_RDR gHC_TYPES (fsLit "LT")
eqTag_RDR               = dataQual_RDR gHC_TYPES (fsLit "EQ")
gtTag_RDR               = dataQual_RDR gHC_TYPES (fsLit "GT")
634

Ian Lynagh's avatar
Ian Lynagh committed
635 636
eqClass_RDR, numClass_RDR, ordClass_RDR, enumClass_RDR, monadClass_RDR
    :: RdrName
637 638 639 640 641
eqClass_RDR             = nameRdrName eqClassName
numClass_RDR            = nameRdrName numClassName
ordClass_RDR            = nameRdrName ordClassName
enumClass_RDR           = nameRdrName enumClassName
monadClass_RDR          = nameRdrName monadClassName
642

Ian Lynagh's avatar
Ian Lynagh committed
643
map_RDR, append_RDR :: RdrName
644 645
map_RDR                 = varQual_RDR gHC_BASE (fsLit "map")
append_RDR              = varQual_RDR gHC_BASE (fsLit "++")
646

quchen's avatar
quchen committed
647
foldr_RDR, build_RDR, returnM_RDR, bindM_RDR, failM_RDR_preMFP, failM_RDR:: RdrName
648 649 650 651
foldr_RDR               = nameRdrName foldrName
build_RDR               = nameRdrName buildName
returnM_RDR             = nameRdrName returnMName
bindM_RDR               = nameRdrName bindMName
quchen's avatar
quchen committed
652
failM_RDR_preMFP        = nameRdrName failMName_preMFP
653
failM_RDR               = nameRdrName failMName
654

Ian Lynagh's avatar
Ian Lynagh committed
655
left_RDR, right_RDR :: RdrName
656 657
left_RDR                = nameRdrName leftDataConName
right_RDR               = nameRdrName rightDataConName
658

Ian Lynagh's avatar
Ian Lynagh committed
659
fromEnum_RDR, toEnum_RDR :: RdrName
660 661
fromEnum_RDR            = varQual_RDR gHC_ENUM (fsLit "fromEnum")
toEnum_RDR              = varQual_RDR gHC_ENUM (fsLit "toEnum")
662

Ian Lynagh's avatar
Ian Lynagh committed
663
enumFrom_RDR, enumFromTo_RDR, enumFromThen_RDR, enumFromThenTo_RDR :: RdrName
664 665 666 667
enumFrom_RDR            = nameRdrName enumFromName
enumFromTo_RDR          = nameRdrName enumFromToName
enumFromThen_RDR        = nameRdrName enumFromThenName
enumFromThenTo_RDR      = nameRdrName enumFromThenToName
668

Ian Lynagh's avatar
Ian Lynagh committed
669
ratioDataCon_RDR, plusInteger_RDR, timesInteger_RDR :: RdrName
670 671 672
ratioDataCon_RDR        = nameRdrName ratioDataConName
plusInteger_RDR         = nameRdrName plusIntegerName
timesInteger_RDR        = nameRdrName timesIntegerName
673

Ian Lynagh's avatar
Ian Lynagh committed
674
ioDataCon_RDR :: RdrName
675
ioDataCon_RDR           = nameRdrName ioDataConName
676

Ian Lynagh's avatar
Ian Lynagh committed
677 678
eqString_RDR, unpackCString_RDR, unpackCStringFoldr_RDR,
    unpackCStringUtf8_RDR :: RdrName
679 680 681 682
eqString_RDR            = nameRdrName eqStringName
unpackCString_RDR       = nameRdrName unpackCStringName
unpackCStringFoldr_RDR  = nameRdrName unpackCStringFoldrName
unpackCStringUtf8_RDR   = nameRdrName unpackCStringUtf8Name
683

684
newStablePtr_RDR :: RdrName
685
newStablePtr_RDR        = nameRdrName newStablePtrName
686

Ian Lynagh's avatar
Ian Lynagh committed
687
bindIO_RDR, returnIO_RDR :: RdrName
688 689
bindIO_RDR              = nameRdrName bindIOName
returnIO_RDR            = nameRdrName returnIOName
690

Ian Lynagh's avatar
Ian Lynagh committed
691
fromInteger_RDR, fromRational_RDR, minus_RDR, times_RDR, plus_RDR :: RdrName
692 693 694 695
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
696
plus_RDR                = varQual_RDR gHC_NUM (fsLit "+")
Simon Marlow's avatar
Simon Marlow committed
697

Ryan Scott's avatar
Ryan Scott committed
698 699 700 701 702
toInteger_RDR, toRational_RDR, fromIntegral_RDR :: RdrName
toInteger_RDR           = nameRdrName toIntegerName
toRational_RDR          = nameRdrName toRationalName
fromIntegral_RDR        = nameRdrName fromIntegralName

703 704
stringTy_RDR, fromString_RDR :: RdrName
stringTy_RDR            = tcQual_RDR gHC_BASE (fsLit "String")
705
fromString_RDR          = nameRdrName fromStringName
706

707 708 709 710 711
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
712
compose_RDR :: RdrName
713
compose_RDR             = varQual_RDR gHC_BASE (fsLit ".")
Simon Marlow's avatar
Simon Marlow committed
714

Ian Lynagh's avatar
Ian Lynagh committed
715
not_RDR, getTag_RDR, succ_RDR, pred_RDR, minBound_RDR, maxBound_RDR,
716
    and_RDR, range_RDR, inRange_RDR, index_RDR,
Ian Lynagh's avatar
Ian Lynagh committed
717
    unsafeIndex_RDR, unsafeRangeSize_RDR :: RdrName
718 719 720 721
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
722 723 724 725 726
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")
727 728 729
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
730

Ian Lynagh's avatar
Ian Lynagh committed
731
readList_RDR, readListDefault_RDR, readListPrec_RDR, readListPrecDefault_RDR,
732
    readPrec_RDR, parens_RDR, choose_RDR, lexP_RDR, expectP_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
733 734 735 736 737 738 739 740
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")
741
expectP_RDR             = varQual_RDR gHC_READ (fsLit "expectP")
742

Ian Lynagh's avatar
Ian Lynagh committed
743
punc_RDR, ident_RDR, symbol_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
744 745 746
punc_RDR                = dataQual_RDR lEX (fsLit "Punc")
ident_RDR               = dataQual_RDR lEX (fsLit "Ident")
symbol_RDR              = dataQual_RDR lEX (fsLit "Symbol")
747

748
step_RDR, alt_RDR, reset_RDR, prec_RDR, pfail_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
749
step_RDR                = varQual_RDR  rEAD_PREC (fsLit "step")
750
alt_RDR                 = varQual_RDR  rEAD_PREC (fsLit "+++")
Ian Lynagh's avatar
Ian Lynagh committed
751 752
reset_RDR               = varQual_RDR  rEAD_PREC (fsLit "reset")
prec_RDR                = varQual_RDR  rEAD_PREC (fsLit "prec")
753
pfail_RDR               = varQual_RDR  rEAD_PREC (fsLit "pfail")
754

David Feuer's avatar
David Feuer committed
755
showsPrec_RDR, shows_RDR, showString_RDR,
Ben Gamari's avatar
Ben Gamari committed
756
    showSpace_RDR, showCommaSpace_RDR, showParen_RDR :: RdrName
757
showsPrec_RDR           = varQual_RDR gHC_SHOW (fsLit "showsPrec")
thomie's avatar
thomie committed
758
shows_RDR               = varQual_RDR gHC_SHOW (fsLit "shows")
Ian Lynagh's avatar
Ian Lynagh committed
759
showString_RDR          = varQual_RDR gHC_SHOW (fsLit "showString")
760
showSpace_RDR           = varQual_RDR gHC_SHOW (fsLit "showSpace")
Ben Gamari's avatar
Ben Gamari committed
761
showCommaSpace_RDR      = varQual_RDR gHC_SHOW (fsLit "showCommaSpace")
762
showParen_RDR           = varQual_RDR gHC_SHOW (fsLit "showParen")
763

Ian Lynagh's avatar
Ian Lynagh committed
764
undefined_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
765
undefined_RDR = varQual_RDR gHC_ERR (fsLit "undefined")
766

767 768 769 770 771 772
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
773 774 775
  prodDataCon_RDR, comp1DataCon_RDR,
  unPar1_RDR, unRec1_RDR, unK1_RDR, unComp1_RDR,
  from_RDR, from1_RDR, to_RDR, to1_RDR,
776
  datatypeName_RDR, moduleName_RDR, packageName_RDR, isNewtypeName_RDR,
777
  conName_RDR, conFixity_RDR, conIsRecord_RDR, selName_RDR,
778
  prefixDataCon_RDR, infixDataCon_RDR, leftAssocDataCon_RDR,
779 780 781 782 783
  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
784 785 786 787 788 789 790 791 792 793 794 795 796

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
797 798 799 800 801
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")

802
from_RDR  = varQual_RDR gHC_GENERICS (fsLit "from")
803
from1_RDR = varQual_RDR gHC_GENERICS (fsLit "from1")
804
to_RDR    = varQual_RDR gHC_GENERICS (fsLit "to")
805 806 807 808
to1_RDR   = varQual_RDR gHC_GENERICS (fsLit "to1")

datatypeName_RDR  = varQual_RDR gHC_GENERICS (fsLit "datatypeName")
moduleName_RDR    = varQual_RDR gHC_GENERICS (fsLit "moduleName")
809
packageName_RDR   = varQual_RDR gHC_GENERICS (fsLit "packageName")
810
isNewtypeName_RDR = varQual_RDR gHC_GENERICS (fsLit "isNewtype")
811 812 813 814 815 816 817 818 819 820 821
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")

822 823 824 825 826 827 828 829 830 831 832 833 834
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#")
835

David Feuer's avatar
David Feuer committed
836
fmap_RDR, replace_RDR, pure_RDR, ap_RDR, liftA2_RDR, foldable_foldr_RDR,
David Feuer's avatar
David Feuer committed
837 838
    foldMap_RDR, null_RDR, all_RDR, traverse_RDR, mempty_RDR,
    mappend_RDR :: RdrName
839
fmap_RDR                = varQual_RDR gHC_BASE (fsLit "fmap")
David Feuer's avatar
David Feuer committed
840
replace_RDR             = varQual_RDR gHC_BASE (fsLit "<$")
841 842
pure_RDR                = nameRdrName pureAName
ap_RDR                  = nameRdrName apAName
843
liftA2_RDR              = varQual_RDR gHC_BASE (fsLit "liftA2")
844
foldable_foldr_RDR      = varQual_RDR dATA_FOLDABLE       (fsLit "foldr")
845
foldMap_RDR             = varQual_RDR dATA_FOLDABLE       (fsLit "foldMap")
David Feuer's avatar
David Feuer committed
846 847
null_RDR                = varQual_RDR dATA_FOLDABLE       (fsLit "null")
all_RDR                 = varQual_RDR dATA_FOLDABLE       (fsLit "all")
848
traverse_RDR            = varQual_RDR dATA_TRAVERSABLE    (fsLit "traverse")
849 850
mempty_RDR              = varQual_RDR gHC_BASE            (fsLit "mempty")
mappend_RDR             = varQual_RDR gHC_BASE            (fsLit "mappend")
851

852 853 854
eqTyCon_RDR :: RdrName
eqTyCon_RDR = tcQual_RDR dATA_TYPE_EQUALITY (fsLit "~")

855
----------------------
Ian Lynagh's avatar
Ian Lynagh committed
856 857
varQual_RDR, tcQual_RDR, clsQual_RDR, dataQual_RDR
    :: Module -> FastString -> RdrName
858 859 860 861
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)
862

Austin Seipp's avatar
Austin Seipp committed
863 864 865
{-
************************************************************************
*                                                                      *
866
\subsection{Known-key names}
Austin Seipp's avatar
Austin Seipp committed
867 868
*                                                                      *
************************************************************************
869

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

874
--MetaHaskell Extension  add the constrs and the lower case case
875
-- guys as well (perhaps) e.g. see  trueDataConName     below
Austin Seipp's avatar
Austin Seipp committed
876
-}
877

878 879 880
wildCardName :: Name
wildCardName = mkSystemVarName wildCardKey (fsLit "wild")

Ian Lynagh's avatar
Ian Lynagh committed
881
runMainIOName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
882
runMainIOName = varQual gHC_TOP_HANDLER (fsLit "runMainIO") runMainKey
883

884
orderingTyConName, ltDataConName, eqDataConName, gtDataConName :: Name
885 886 887 888
orderingTyConName = tcQual  gHC_TYPES (fsLit "Ordering") orderingTyConKey
ltDataConName     = dcQual gHC_TYPES (fsLit "LT") ltDataConKey
eqDataConName     = dcQual gHC_TYPES (fsLit "EQ") eqDataConKey
gtDataConName     = dcQual gHC_TYPES (fsLit "GT") gtDataConKey
889 890 891

specTyConName :: Name
specTyConName     = tcQual gHC_TYPES (fsLit "SPEC") specTyConKey
Ian Lynagh's avatar
Ian Lynagh committed
892

Ian Lynagh's avatar
Ian Lynagh committed
893
eitherTyConName, leftDataConName, rightDataConName :: Name
894
eitherTyConName   = tcQual  dATA_EITHER (fsLit "Either") eitherTyConKey
895 896
leftDataConName   = dcQual dATA_EITHER (fsLit "Left")   leftDataConKey
rightDataConName  = dcQual dATA_EITHER (fsLit "Right")  rightDataConKey
897

898 899 900
-- Generics (types)
v1TyConName, u1TyConName, par1TyConName, rec1TyConName,
  k1TyConName, m1TyConName, sumTyConName, prodTyConName,
901 902
  compTyConName, rTyConName, dTyConName,
  cTyConName, sTyConName, rec0TyConName,
903
  d1TyConName, c1TyConName, s1TyConName, noSelTyConName,
904 905
  repTyConName, rep1TyConName, uRecTyConName,
  uAddrTyConName, uCharTyConName, uDoubleTyConName,
906 907 908
  uFloatTyConName, uIntTyConName, uWordTyConName,
  prefixIDataConName, infixIDataConName, leftAssociativeDataConName,
  rightAssociativeDataConName, notAssociativeDataConName,
909 910 911 912 913
  sourceUnpackDataConName, sourceNoUnpackDataConName,
  noSourceUnpackednessDataConName, sourceLazyDataConName,
  sourceStrictDataConName, noSourceStrictnessDataConName,
  decidedLazyDataConName, decidedStrictDataConName, decidedUnpackDataConName,
  metaDataDataConName, metaConsDataConName, metaSelDataConName :: Name
914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936

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

937
repTyConName  = tcQual gHC_GENERICS (fsLit "Rep")  repTyConKey
938 939
rep1TyConName = tcQual gHC_GENERICS (fsLit "Rep1") rep1TyConKey

940 941 942 943 944 945 946 947
uRecTyConName      = tcQual gHC_GENERICS (fsLit "URec") uRecTyConKey
uAddrTyConName     = tcQual gHC_GENERICS (fsLit "UAddr") uAddrTyConKey
uCharTyConName     = tcQual gHC_GENERICS (fsLit "UChar") uCharTyConKey
uDoubleTyConName   = tcQual gHC_GENERICS (fsLit "UDouble") uDoubleTyConKey
uFloatTyConName    = tcQual gHC_GENERICS (fsLit "UFloat") uFloatTyConKey
uIntTyConName      = tcQual gHC_GENERICS (fsLit "UInt") uIntTyConKey
uWordTyConName     = tcQual gHC_GENERICS (fsLit "UWord") uWordTyConKey

948 949 950 951 952 953
prefixIDataConName = dcQual gHC_GENERICS (fsLit "PrefixI")  prefixIDataConKey
infixIDataConName  = dcQual gHC_GENERICS (fsLit "InfixI")   infixIDataConKey
leftAssociativeDataConName  = dcQual gHC_GENERICS (fsLit "LeftAssociative")   leftAssociativeDataConKey
rightAssociativeDataConName = dcQual gHC_GENERICS (fsLit "RightAssociative")  rightAssociativeDataConKey
notAssociativeDataConName   = dcQual gHC_GENERICS (fsLit "NotAssociative")    notAssociativeDataConKey

954 955 956 957 958 959 960 961 962 963
sourceUnpackDataConName         = dcQual gHC_GENERICS (fsLit "SourceUnpack")         sourceUnpackDataConKey
sourceNoUnpackDataConName       = dcQual gHC_GENERICS (fsLit "SourceNoUnpack")       sourceNoUnpackDataConKey
noSourceUnpackednessDataConName = dcQual gHC_GENERICS (fsLit "NoSourceUnpackedness") noSourceUnpackednessDataConKey
sourceLazyDataConName           = dcQual gHC_GENERICS (fsLit "SourceLazy")           sourceLazyDataConKey
sourceStrictDataConName         = dcQual gHC_GENERICS (fsLit "SourceStrict")         sourceStrictDataConKey
noSourceStrictnessDataConName   = dcQual gHC_GENERICS (fsLit "NoSourceStrictness")   noSourceStrictnessDataConKey
decidedLazyDataConName          = dcQual gHC_GENERICS (fsLit "DecidedLazy")          decidedLazyDataConKey
decidedStrictDataConName        = dcQual gHC_GENERICS (fsLit "DecidedStrict")        decidedStrictDataConKey
decidedUnpackDataConName        = dcQual gHC_GENERICS (fsLit "DecidedUnpack")        decidedUnpackDataConKey

964 965 966 967
metaDataDataConName  = dcQual gHC_GENERICS (fsLit "MetaData")  metaDataDataConKey
metaConsDataConName  = dcQual gHC_GENERICS (fsLit "MetaCons")  metaConsDataConKey
metaSelDataConName   = dcQual gHC_GENERICS (fsLit "MetaSel")   metaSelDataConKey

968 969 970 971 972
-- Primitive Int
divIntName, modIntName :: Name
divIntName = varQual gHC_CLASSES (fsLit "divInt#") divIntIdKey
modIntName = varQual gHC_CLASSES (fsLit "modInt#") modIntIdKey

973
-- Base strings Strings
Ian Lynagh's avatar
Ian Lynagh committed
974
unpackCStringName, unpackCStringFoldrName,
975
    unpackCStringUtf8Name, eqStringName :: Name
976 977 978
unpackCStringName       = varQual gHC_CSTRING (fsLit "unpackCString#") unpackCStringIdKey
unpackCStringFoldrName  = varQual gHC_CSTRING (fsLit "unpackFoldrCString#") unpackCStringFoldrIdKey
unpackCStringUtf8Name   = varQual gHC_CSTRING (fsLit "unpackCStringUtf8#") unpackCStringUtf8IdKey
979
eqStringName            = varQual gHC_BASE (fsLit "eqString")  eqStringIdKey
980

981
-- The 'inline' function
Ian Lynagh's avatar
Ian Lynagh committed
982
inlineIdName :: Name
983
inlineIdName            = varQual gHC_MAGIC (fsLit "inline") inlineIdKey
984

985
-- Base classes (Eq, Ord, Functor)
986
fmapName, eqClassName, eqName, ordClassName, geName, functorClassName :: Name
Jan Stolarek's avatar
Jan Stolarek committed
987