PrelNames.lhs 82.9 KB
Newer Older
1 2 3
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
4 5 6
\section[PrelNames]{Definitions of prelude modules and names}


7
Nota Bene: all Names defined in here should come from the base package
8

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

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

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

20
 - Names for Ids, DataCons, TyCons and Classes that the compiler
Thomas Schilling's avatar
Thomas Schilling committed
21
   "knows about" in some way
22 23
        e.g.    intTyConName :: Name
                minusName    :: Name
Thomas Schilling's avatar
Thomas Schilling committed
24
   One of these Names contains
25 26
        (a) the module and occurrence name of the thing
        (b) its Unique
Thomas Schilling's avatar
Thomas Schilling committed
27 28 29 30 31
   The may way the compiler "knows about" one of these things is
   where the type checker or desugarer needs to look it up. For
   example, when desugaring list comprehensions the desugarer
   needs to conjure up 'foldr'.  It does this by looking up
   foldrName in the environment.
32

Thomas Schilling's avatar
Thomas Schilling committed
33 34 35
 - RdrNames for Ids, DataCons etc that the compiler may emit into
   generated code (e.g. for deriving).  It's not necessary to know
   the uniques for these guys, only their names
36

37

38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
Note [Known-key names]
~~~~~~~~~~~~~~~~~~~~~~

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

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

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

This is accomplished through a combination of mechanisms:

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

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

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

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

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

     This is accomplished through a variety of mechanisms:

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

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

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

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

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

#include "HsVersions.h"

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

113

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

This *local* name is used by the interactive stuff

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

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

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


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

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

148
The names for DPH can come from one of multiple backend packages. At the point where
149 150 151 152 153
'basicKnownKeyNames' is used, we don't know which backend it will be.  Hence, we list
the names for multiple backends.  That works out fine, although they use the same uniques,
as we are guaranteed to only load one backend; hence, only one of the different names
sharing a unique will be used.

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

        --  Classes.  *Must* include:
        --      classes that are grabbed by key (e.g., eqClassKey)
        --      classes in "Class.standardClassKeys" (quite a few)
        eqClassName,                    -- mentioned, derivable
        ordClassName,                   -- derivable
        boundedClassName,               -- derivable
        numClassName,                   -- mentioned, numeric
        enumClassName,                  -- derivable
        monadClassName,
        functorClassName,
        realClassName,                  -- numeric
        integralClassName,              -- numeric
        fractionalClassName,            -- numeric
        floatingClassName,              -- numeric
        realFracClassName,              -- numeric
        realFloatClassName,             -- numeric
        dataClassName,
        isStringClassName,
        applicativeClassName,
        foldableClassName,
        traversableClassName,
189
        typeableClassName,              -- derivable
190 191

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

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

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

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

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

211 212
        -- MonadRec stuff
        mfixName,
213

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

218 219
        -- Ix stuff
        ixClassName,
220

221 222
        -- Show stuff
        showClassName,
223

224 225
        -- Read stuff
        readClassName,
226

227 228
        -- Stable pointers
        newStablePtrName,
229

230
        -- GHC Extensions
231
        groupWithName,
232

233 234 235
        -- Strings and lists
        unpackCStringName,
        unpackCStringFoldrName, unpackCStringUtf8Name,
236 237 238 239 240 241 242
        
        -- Overloaded lists
        isListClassName,
        fromListName,
        fromListNName,
        toListName,
        
243 244 245
        -- List operations
        concatName, filterName, mapName,
        zipName, foldrName, buildName, augmentName, appendName,
246

247
        dollarName,         -- The ($) apply function
248

249 250 251 252
        -- FFI primitive types that are not wired-in.
        stablePtrTyConName, ptrTyConName, funPtrTyConName,
        int8TyConName, int16TyConName, int32TyConName, int64TyConName,
        wordTyConName, word8TyConName, word16TyConName, word32TyConName, word64TyConName,
253

254 255 256
        -- Others
        otherwiseIdName, inlineIdName,
        eqStringName, assertName, breakpointName, breakpointCondName,
257
        breakpointAutoName,  opaqueTyConName,
David Himmelstrup's avatar
David Himmelstrup committed
258
        assertErrorName, runSTRepName,
259
        printName, fstName, sndName,
260

261
        -- Integer
262
        integerTyConName, mkIntegerName,
263
        integerToWord64Name, integerToInt64Name,
Ian Lynagh's avatar
Ian Lynagh committed
264
        word64ToIntegerName, int64ToIntegerName,
265
        plusIntegerName, timesIntegerName, smallIntegerName,
266
        wordToIntegerName,
267 268 269 270
        integerToWordName, integerToIntName, minusIntegerName,
        negateIntegerName, eqIntegerName, neqIntegerName,
        absIntegerName, signumIntegerName,
        leIntegerName, gtIntegerName, ltIntegerName, geIntegerName,
Ian Lynagh's avatar
Ian Lynagh committed
271
        compareIntegerName, quotRemIntegerName, divModIntegerName,
272
        quotIntegerName, remIntegerName,
273
        floatFromIntegerName, doubleFromIntegerName,
274
        encodeFloatIntegerName, encodeDoubleIntegerName,
Ian Lynagh's avatar
Ian Lynagh committed
275
        decodeDoubleIntegerName,
276 277 278 279
        gcdIntegerName, lcmIntegerName,
        andIntegerName, orIntegerName, xorIntegerName, complementIntegerName,
        shiftLIntegerName, shiftRIntegerName,

280 281 282 283
        -- Float/Double
        rationalToFloatName,
        rationalToDoubleName,

284 285
        -- MonadFix
        monadFixClassName, mfixName,
286

287 288
        -- Other classes
        randomClassName, randomGenClassName, monadPlusClassName,
289

290
        -- Type-level naturals
291
        singIClassName,
292 293 294 295 296
        typeNatLeqClassName,
        typeNatAddTyFamName,
        typeNatMulTyFamName,
        typeNatExpTyFamName,

297 298 299
        -- Implicit parameters
        ipClassName,

300
        -- Annotation type checking
301
        toAnnotationWrapperName
302

303 304 305
        -- The Ordering type
        , orderingTyConName, ltDataConName, eqDataConName, gtDataConName

306 307
        -- The Either type
        , eitherTyConName, leftDataConName, rightDataConName
308

309 310
        -- Plugins
        , pluginTyConName
311 312 313 314 315 316 317 318 319

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

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

320 321 322 323
        -- Monad comprehensions
        , guardMName
        , liftMName
        , mzipName
dterei's avatar
dterei committed
324 325 326

        -- GHCi Sandbox
        , ghciIoClassName, ghciStepIoMName
327
    ]
328

329
genericTyConNames :: [Name]
330 331 332 333 334 335
genericTyConNames = [
    v1TyConName, u1TyConName, par1TyConName, rec1TyConName,
    k1TyConName, m1TyConName, sumTyConName, prodTyConName,
    compTyConName, rTyConName, pTyConName, dTyConName,
    cTyConName, sTyConName, rec0TyConName, par0TyConName,
    d1TyConName, c1TyConName, s1TyConName, noSelTyConName,
336
    repTyConName, rep1TyConName
337
  ]
338 339 340
\end{code}


341
%************************************************************************
342
%*                                                                      *
343
\subsection{Module names}
344
%*                                                                      *
345 346
%************************************************************************

347 348

--MetaHaskell Extension Add a new module here
349
\begin{code}
Ian Lynagh's avatar
Ian Lynagh committed
350
pRELUDE :: Module
351
pRELUDE         = mkBaseModule_ pRELUDE_NAME
Ian Lynagh's avatar
Ian Lynagh committed
352

Ian Lynagh's avatar
Ian Lynagh committed
353
gHC_PRIM, gHC_TYPES, gHC_GENERICS,
Ian Lynagh's avatar
Ian Lynagh committed
354
    gHC_MAGIC,
dterei's avatar
dterei committed
355
    gHC_CLASSES, gHC_BASE, gHC_ENUM, gHC_GHCI, gHC_CSTRING,
356
    gHC_SHOW, gHC_READ, gHC_NUM, gHC_INTEGER_TYPE, gHC_LIST,
357
    gHC_TUPLE, dATA_TUPLE, dATA_EITHER, dATA_STRING, dATA_FOLDABLE, dATA_TRAVERSABLE, dATA_MONOID,
dterei's avatar
dterei committed
358 359
    gHC_CONC, gHC_IO, gHC_IO_Exception,
    gHC_ST, gHC_ARR, gHC_STABLE, gHC_PTR, gHC_ERR, gHC_REAL,
360 361
    gHC_FLOAT, gHC_TOP_HANDLER, sYSTEM_IO, dYNAMIC,
    tYPEABLE, tYPEABLE_INTERNAL, oLDTYPEABLE, oLDTYPEABLE_INTERNAL, gENERICS,
362
    dOTNET, rEAD_PREC, lEX, gHC_INT, gHC_WORD, mONAD, mONAD_FIX, mONAD_ZIP,
363
    aRROW, cONTROL_APPLICATIVE, gHC_DESUGAR, rANDOM, gHC_EXTS,
364
    cONTROL_EXCEPTION_BASE, gHC_TYPELITS, gHC_IP :: Module
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
365

366
gHC_PRIM        = mkPrimModule (fsLit "GHC.Prim")   -- Primitive types and values
simonpj@microsoft.com's avatar
simonpj@microsoft.com committed
367
gHC_TYPES       = mkPrimModule (fsLit "GHC.Types")
368 369 370 371 372 373
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
374
gHC_GHCI        = mkBaseModule (fsLit "GHC.GHCi")
375 376 377
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
378
gHC_INTEGER_TYPE= mkIntegerModule (fsLit "GHC.Integer.Type")
379 380 381
gHC_LIST        = mkBaseModule (fsLit "GHC.List")
gHC_TUPLE       = mkPrimModule (fsLit "GHC.Tuple")
dATA_TUPLE      = mkBaseModule (fsLit "Data.Tuple")
382 383 384
dATA_EITHER     = mkBaseModule (fsLit "Data.Either")
dATA_STRING     = mkBaseModule (fsLit "Data.String")
dATA_FOLDABLE   = mkBaseModule (fsLit "Data.Foldable")
385
dATA_TRAVERSABLE= mkBaseModule (fsLit "Data.Traversable")
386
dATA_MONOID     = mkBaseModule (fsLit "Data.Monoid")
387 388
gHC_CONC        = mkBaseModule (fsLit "GHC.Conc")
gHC_IO          = mkBaseModule (fsLit "GHC.IO")
389
gHC_IO_Exception = mkBaseModule (fsLit "GHC.IO.Exception")
390 391 392 393 394 395 396 397 398 399
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")
400 401
tYPEABLE        = mkBaseModule (fsLit "Data.Typeable")
tYPEABLE_INTERNAL = mkBaseModule (fsLit "Data.Typeable.Internal")
402 403
oLDTYPEABLE     = mkBaseModule (fsLit "Data.OldTypeable")
oLDTYPEABLE_INTERNAL = mkBaseModule (fsLit "Data.OldTypeable.Internal")
404
gENERICS        = mkBaseModule (fsLit "Data.Data")
405 406 407 408 409 410 411
dOTNET          = mkBaseModule (fsLit "GHC.Dotnet")
rEAD_PREC       = mkBaseModule (fsLit "Text.ParserCombinators.ReadPrec")
lEX             = mkBaseModule (fsLit "Text.Read.Lex")
gHC_INT         = mkBaseModule (fsLit "GHC.Int")
gHC_WORD        = mkBaseModule (fsLit "GHC.Word")
mONAD           = mkBaseModule (fsLit "Control.Monad")
mONAD_FIX       = mkBaseModule (fsLit "Control.Monad.Fix")
412
mONAD_ZIP       = mkBaseModule (fsLit "Control.Monad.Zip")
413
aRROW           = mkBaseModule (fsLit "Control.Arrow")
414
cONTROL_APPLICATIVE = mkBaseModule (fsLit "Control.Applicative")
Ian Lynagh's avatar
Ian Lynagh committed
415
gHC_DESUGAR = mkBaseModule (fsLit "GHC.Desugar")
416 417
rANDOM          = mkBaseModule (fsLit "System.Random")
gHC_EXTS        = mkBaseModule (fsLit "GHC.Exts")
418
cONTROL_EXCEPTION_BASE = mkBaseModule (fsLit "Control.Exception.Base")
jpm@cs.ox.ac.uk's avatar
jpm@cs.ox.ac.uk committed
419
gHC_GENERICS    = mkBaseModule (fsLit "GHC.Generics")
420
gHC_TYPELITS    = mkBaseModule (fsLit "GHC.TypeLits")
421
gHC_IP          = mkBaseModule (fsLit "GHC.IP")
Simon Marlow's avatar
Simon Marlow committed
422

423 424 425
gHC_PARR' :: Module
gHC_PARR' = mkBaseModule (fsLit "GHC.PArr")

Ian Lynagh's avatar
Ian Lynagh committed
426
mAIN, rOOT_MAIN :: Module
427 428
mAIN            = mkMainModule_ mAIN_NAME
rOOT_MAIN       = mkMainModule (fsLit ":Main") -- Root module for initialisation
Simon Marlow's avatar
Simon Marlow committed
429

430 431 432 433
        -- The ':xxx' makes a module name that the user can never
        -- use himself.  The z-encoding for ':' is "ZC", so the z-encoded
        -- module name still starts with a capital letter, which keeps
        -- the z-encoded version consistent.
434
iNTERACTIVE :: Module
Ian Lynagh's avatar
Ian Lynagh committed
435
iNTERACTIVE    = mkMainModule (fsLit ":Interactive")
Simon Marlow's avatar
Simon Marlow committed
436

Ian Lynagh's avatar
Ian Lynagh committed
437
pRELUDE_NAME, mAIN_NAME :: ModuleName
Ian Lynagh's avatar
Ian Lynagh committed
438 439
pRELUDE_NAME   = mkModuleNameFS (fsLit "Prelude")
mAIN_NAME      = mkModuleNameFS (fsLit "Main")
Simon Marlow's avatar
Simon Marlow committed
440

441 442 443 444
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
445 446 447 448 449 450
mkPrimModule :: FastString -> Module
mkPrimModule m = mkModule primPackageId (mkModuleNameFS m)

mkIntegerModule :: FastString -> Module
mkIntegerModule m = mkModule integerPackageId (mkModuleNameFS m)

Simon Marlow's avatar
Simon Marlow committed
451 452 453 454 455 456
mkBaseModule :: FastString -> Module
mkBaseModule m = mkModule basePackageId (mkModuleNameFS m)

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

457 458 459 460 461 462
mkThisGhcModule :: FastString -> Module
mkThisGhcModule m = mkModule thisGhcPackageId (mkModuleNameFS m)

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

Simon Marlow's avatar
Simon Marlow committed
463 464
mkMainModule :: FastString -> Module
mkMainModule m = mkModule mainPackageId (mkModuleNameFS m)
465

Simon Marlow's avatar
Simon Marlow committed
466 467
mkMainModule_ :: ModuleName -> Module
mkMainModule_ m = mkModule mainPackageId m
468 469 470
\end{code}

%************************************************************************
471
%*                                                                      *
472
\subsection{Constructing the names of tuples
473
%*                                                                      *
474 475 476
%************************************************************************

\begin{code}
batterseapower's avatar
batterseapower committed
477 478
mkTupleModule :: TupleSort -> Arity -> Module
mkTupleModule BoxedTuple   _ = gHC_TUPLE
479
mkTupleModule ConstraintTuple    _ = gHC_TUPLE
batterseapower's avatar
batterseapower committed
480
mkTupleModule UnboxedTuple _ = gHC_PRIM
481 482 483
\end{code}


484
%************************************************************************
485 486 487
%*                                                                      *
                        RdrNames
%*                                                                      *
488 489 490
%************************************************************************

\begin{code}
Ian Lynagh's avatar
Ian Lynagh committed
491
main_RDR_Unqual    :: RdrName
492 493 494
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
495

496
forall_tv_RDR, dot_tv_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
497 498
forall_tv_RDR = mkUnqual tvName (fsLit "forall")
dot_tv_RDR    = mkUnqual tvName (fsLit ".")
499

Ian Lynagh's avatar
Ian Lynagh committed
500 501
eq_RDR, ge_RDR, ne_RDR, le_RDR, lt_RDR, gt_RDR, compare_RDR,
    ltTag_RDR, eqTag_RDR, gtTag_RDR :: RdrName
502 503 504 505 506 507 508
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
509 510 511
ltTag_RDR               = dataQual_RDR gHC_TYPES (fsLit "LT")
eqTag_RDR               = dataQual_RDR gHC_TYPES (fsLit "EQ")
gtTag_RDR               = dataQual_RDR gHC_TYPES (fsLit "GT")
512

Ian Lynagh's avatar
Ian Lynagh committed
513 514
eqClass_RDR, numClass_RDR, ordClass_RDR, enumClass_RDR, monadClass_RDR
    :: RdrName
515 516 517 518 519
eqClass_RDR             = nameRdrName eqClassName
numClass_RDR            = nameRdrName numClassName
ordClass_RDR            = nameRdrName ordClassName
enumClass_RDR           = nameRdrName enumClassName
monadClass_RDR          = nameRdrName monadClassName
520

Ian Lynagh's avatar
Ian Lynagh committed
521
map_RDR, append_RDR :: RdrName
522 523
map_RDR                 = varQual_RDR gHC_BASE (fsLit "map")
append_RDR              = varQual_RDR gHC_BASE (fsLit "++")
524

Ian Lynagh's avatar
Ian Lynagh committed
525
foldr_RDR, build_RDR, returnM_RDR, bindM_RDR, failM_RDR :: RdrName
526 527 528 529 530
foldr_RDR               = nameRdrName foldrName
build_RDR               = nameRdrName buildName
returnM_RDR             = nameRdrName returnMName
bindM_RDR               = nameRdrName bindMName
failM_RDR               = nameRdrName failMName
531

Ian Lynagh's avatar
Ian Lynagh committed
532
left_RDR, right_RDR :: RdrName
533 534
left_RDR                = nameRdrName leftDataConName
right_RDR               = nameRdrName rightDataConName
535

Ian Lynagh's avatar
Ian Lynagh committed
536
fromEnum_RDR, toEnum_RDR :: RdrName
537 538
fromEnum_RDR            = varQual_RDR gHC_ENUM (fsLit "fromEnum")
toEnum_RDR              = varQual_RDR gHC_ENUM (fsLit "toEnum")
539

Ian Lynagh's avatar
Ian Lynagh committed
540
enumFrom_RDR, enumFromTo_RDR, enumFromThen_RDR, enumFromThenTo_RDR :: RdrName
541 542 543 544
enumFrom_RDR            = nameRdrName enumFromName
enumFromTo_RDR          = nameRdrName enumFromToName
enumFromThen_RDR        = nameRdrName enumFromThenName
enumFromThenTo_RDR      = nameRdrName enumFromThenToName
545

Ian Lynagh's avatar
Ian Lynagh committed
546
ratioDataCon_RDR, plusInteger_RDR, timesInteger_RDR :: RdrName
547 548 549
ratioDataCon_RDR        = nameRdrName ratioDataConName
plusInteger_RDR         = nameRdrName plusIntegerName
timesInteger_RDR        = nameRdrName timesIntegerName
550

Ian Lynagh's avatar
Ian Lynagh committed
551
ioDataCon_RDR :: RdrName
552
ioDataCon_RDR           = nameRdrName ioDataConName
553

Ian Lynagh's avatar
Ian Lynagh committed
554 555
eqString_RDR, unpackCString_RDR, unpackCStringFoldr_RDR,
    unpackCStringUtf8_RDR :: RdrName
556 557 558 559
eqString_RDR            = nameRdrName eqStringName
unpackCString_RDR       = nameRdrName unpackCStringName
unpackCStringFoldr_RDR  = nameRdrName unpackCStringFoldrName
unpackCStringUtf8_RDR   = nameRdrName unpackCStringUtf8Name
560

Ian Lynagh's avatar
Ian Lynagh committed
561
newStablePtr_RDR, wordDataCon_RDR :: RdrName
562
newStablePtr_RDR        = nameRdrName newStablePtrName
563
wordDataCon_RDR         = dataQual_RDR gHC_TYPES (fsLit "W#")
564

Ian Lynagh's avatar
Ian Lynagh committed
565
bindIO_RDR, returnIO_RDR :: RdrName
566 567
bindIO_RDR              = nameRdrName bindIOName
returnIO_RDR            = nameRdrName returnIOName
568

Ian Lynagh's avatar
Ian Lynagh committed
569
fromInteger_RDR, fromRational_RDR, minus_RDR, times_RDR, plus_RDR :: RdrName
570 571 572 573
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
574
plus_RDR                = varQual_RDR gHC_NUM (fsLit "+")
Simon Marlow's avatar
Simon Marlow committed
575

Ian Lynagh's avatar
Ian Lynagh committed
576
fromString_RDR :: RdrName
577
fromString_RDR          = nameRdrName fromStringName
578

579 580 581 582 583
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
584
compose_RDR :: RdrName
585
compose_RDR             = varQual_RDR gHC_BASE (fsLit ".")
Simon Marlow's avatar
Simon Marlow committed
586

Ian Lynagh's avatar
Ian Lynagh committed
587
not_RDR, getTag_RDR, succ_RDR, pred_RDR, minBound_RDR, maxBound_RDR,
588
    and_RDR, range_RDR, inRange_RDR, index_RDR,
Ian Lynagh's avatar
Ian Lynagh committed
589
    unsafeIndex_RDR, unsafeRangeSize_RDR :: RdrName
590 591 592 593
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
594 595 596 597 598
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")
599 600 601
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
602

Ian Lynagh's avatar
Ian Lynagh committed
603
readList_RDR, readListDefault_RDR, readListPrec_RDR, readListPrecDefault_RDR,
604
    readPrec_RDR, parens_RDR, choose_RDR, lexP_RDR, expectP_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
605 606 607 608 609 610 611 612
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")
613
expectP_RDR             = varQual_RDR gHC_READ (fsLit "expectP")
614

Ian Lynagh's avatar
Ian Lynagh committed
615
punc_RDR, ident_RDR, symbol_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
616 617 618
punc_RDR                = dataQual_RDR lEX (fsLit "Punc")
ident_RDR               = dataQual_RDR lEX (fsLit "Ident")
symbol_RDR              = dataQual_RDR lEX (fsLit "Symbol")
619

Ian Lynagh's avatar
Ian Lynagh committed
620
step_RDR, alt_RDR, reset_RDR, prec_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
621
step_RDR                = varQual_RDR  rEAD_PREC (fsLit "step")
622
alt_RDR                 = varQual_RDR  rEAD_PREC (fsLit "+++")
Ian Lynagh's avatar
Ian Lynagh committed
623 624
reset_RDR               = varQual_RDR  rEAD_PREC (fsLit "reset")
prec_RDR                = varQual_RDR  rEAD_PREC (fsLit "prec")
625

Ian Lynagh's avatar
Ian Lynagh committed
626 627
showList_RDR, showList___RDR, showsPrec_RDR, showString_RDR,
    showSpace_RDR, showParen_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
628 629
showList_RDR            = varQual_RDR gHC_SHOW (fsLit "showList")
showList___RDR          = varQual_RDR gHC_SHOW (fsLit "showList__")
630
showsPrec_RDR           = varQual_RDR gHC_SHOW (fsLit "showsPrec")
Ian Lynagh's avatar
Ian Lynagh committed
631
showString_RDR          = varQual_RDR gHC_SHOW (fsLit "showString")
632 633
showSpace_RDR           = varQual_RDR gHC_SHOW (fsLit "showSpace")
showParen_RDR           = varQual_RDR gHC_SHOW (fsLit "showParen")
634

635 636 637 638 639 640 641 642
typeRep_RDR, mkTyCon_RDR, mkTyConApp_RDR,
    oldTypeOf_RDR, oldMkTyCon_RDR, oldMkTyConApp_RDR :: RdrName
typeRep_RDR       = varQual_RDR tYPEABLE_INTERNAL    (fsLit "typeRep")
mkTyCon_RDR       = varQual_RDR tYPEABLE_INTERNAL    (fsLit "mkTyCon")
mkTyConApp_RDR    = varQual_RDR tYPEABLE_INTERNAL    (fsLit "mkTyConApp")
oldTypeOf_RDR     = varQual_RDR oLDTYPEABLE_INTERNAL (fsLit "typeOf")
oldMkTyCon_RDR    = varQual_RDR oLDTYPEABLE_INTERNAL (fsLit "mkTyCon")
oldMkTyConApp_RDR = varQual_RDR oLDTYPEABLE_INTERNAL (fsLit "mkTyConApp")
643

Ian Lynagh's avatar
Ian Lynagh committed
644
undefined_RDR :: RdrName
Ian Lynagh's avatar
Ian Lynagh committed
645
undefined_RDR = varQual_RDR gHC_ERR (fsLit "undefined")
646

647 648 649 650 651 652
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
653 654 655
  prodDataCon_RDR, comp1DataCon_RDR,
  unPar1_RDR, unRec1_RDR, unK1_RDR, unComp1_RDR,
  from_RDR, from1_RDR, to_RDR, to1_RDR,
656 657
  datatypeName_RDR, moduleName_RDR, isNewtypeName_RDR,
  conName_RDR, conFixity_RDR, conIsRecord_RDR,
658
  noArityDataCon_RDR, arityDataCon_RDR, selName_RDR,
659 660 661 662 663 664 665 666 667 668 669 670 671 672 673
  prefixDataCon_RDR, infixDataCon_RDR, leftAssocDataCon_RDR,
  rightAssocDataCon_RDR, notAssocDataCon_RDR :: RdrName

u1DataCon_RDR    = dataQual_RDR gHC_GENERICS (fsLit "U1")
par1DataCon_RDR  = dataQual_RDR gHC_GENERICS (fsLit "Par1")
rec1DataCon_RDR  = dataQual_RDR gHC_GENERICS (fsLit "Rec1")
k1DataCon_RDR    = dataQual_RDR gHC_GENERICS (fsLit "K1")
m1DataCon_RDR    = dataQual_RDR gHC_GENERICS (fsLit "M1")

l1DataCon_RDR     = dataQual_RDR gHC_GENERICS (fsLit "L1")
r1DataCon_RDR     = dataQual_RDR gHC_GENERICS (fsLit "R1")

prodDataCon_RDR   = dataQual_RDR gHC_GENERICS (fsLit ":*:")
comp1DataCon_RDR  = dataQual_RDR gHC_GENERICS (fsLit "Comp1")

jpm@cs.ox.ac.uk's avatar
jpm@cs.ox.ac.uk committed
674 675 676 677 678
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")

679
from_RDR  = varQual_RDR gHC_GENERICS (fsLit "from")
680
from1_RDR = varQual_RDR gHC_GENERICS (fsLit "from1")
681
to_RDR    = varQual_RDR gHC_GENERICS (fsLit "to")
682 683 684 685
to1_RDR   = varQual_RDR gHC_GENERICS (fsLit "to1")

datatypeName_RDR  = varQual_RDR gHC_GENERICS (fsLit "datatypeName")
moduleName_RDR    = varQual_RDR gHC_GENERICS (fsLit "moduleName")
686
isNewtypeName_RDR = varQual_RDR gHC_GENERICS (fsLit "isNewtype")
687 688 689 690 691 692 693 694 695 696 697 698 699 700
selName_RDR       = varQual_RDR gHC_GENERICS (fsLit "selName")
conName_RDR       = varQual_RDR gHC_GENERICS (fsLit "conName")
conFixity_RDR     = varQual_RDR gHC_GENERICS (fsLit "conFixity")
conIsRecord_RDR   = varQual_RDR gHC_GENERICS (fsLit "conIsRecord")

noArityDataCon_RDR    = dataQual_RDR gHC_GENERICS (fsLit "NoArity")
arityDataCon_RDR      = dataQual_RDR gHC_GENERICS (fsLit "Arity")
prefixDataCon_RDR     = dataQual_RDR gHC_GENERICS (fsLit "Prefix")
infixDataCon_RDR      = dataQual_RDR gHC_GENERICS (fsLit "Infix")
leftAssocDataCon_RDR  = dataQual_RDR gHC_GENERICS (fsLit "LeftAssociative")
rightAssocDataCon_RDR = dataQual_RDR gHC_GENERICS (fsLit "RightAssociative")
notAssocDataCon_RDR   = dataQual_RDR gHC_GENERICS (fsLit "NotAssociative")


701 702
fmap_RDR, pure_RDR, ap_RDR, foldable_foldr_RDR, foldMap_RDR,
    traverse_RDR, mempty_RDR, mappend_RDR :: RdrName
703 704 705 706
fmap_RDR                = varQual_RDR gHC_BASE (fsLit "fmap")
pure_RDR                = varQual_RDR cONTROL_APPLICATIVE (fsLit "pure")
ap_RDR                  = varQual_RDR cONTROL_APPLICATIVE (fsLit "<*>")
foldable_foldr_RDR      = varQual_RDR dATA_FOLDABLE       (fsLit "foldr")
707
foldMap_RDR             = varQual_RDR dATA_FOLDABLE       (fsLit "foldMap")
708
traverse_RDR            = varQual_RDR dATA_TRAVERSABLE    (fsLit "traverse")
709 710
mempty_RDR              = varQual_RDR dATA_MONOID         (fsLit "mempty")
mappend_RDR             = varQual_RDR dATA_MONOID         (fsLit "mappend")
711

712
----------------------
Ian Lynagh's avatar
Ian Lynagh committed
713 714
varQual_RDR, tcQual_RDR, clsQual_RDR, dataQual_RDR
    :: Module -> FastString -> RdrName
715 716 717 718
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)
719
\end{code}
720

721
%************************************************************************
722
%*                                                                      *
723
\subsection{Known-key names}
724
%*                                                                      *
725 726
%************************************************************************

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

731
--MetaHaskell Extension  add the constrs and the lower case case
732
-- guys as well (perhaps) e.g. see  trueDataConName     below
733 734


735
\begin{code}
736 737 738
wildCardName :: Name
wildCardName = mkSystemVarName wildCardKey (fsLit "wild")

Ian Lynagh's avatar
Ian Lynagh committed
739
runMainIOName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
740
runMainIOName = varQual gHC_TOP_HANDLER (fsLit "runMainIO") runMainKey
741

742
orderingTyConName, ltDataConName, eqDataConName, gtDataConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
743 744 745 746
orderingTyConName = tcQual   gHC_TYPES (fsLit "Ordering") orderingTyConKey
ltDataConName = conName gHC_TYPES (fsLit "LT") ltDataConKey
eqDataConName = conName gHC_TYPES (fsLit "EQ") eqDataConKey
gtDataConName = conName gHC_TYPES (fsLit "GT") gtDataConKey
Ian Lynagh's avatar
Ian Lynagh committed
747

Ian Lynagh's avatar
Ian Lynagh committed
748
eitherTyConName, leftDataConName, rightDataConName :: Name
749
eitherTyConName   = tcQual  dATA_EITHER (fsLit "Either") eitherTyConKey
Ian Lynagh's avatar
Ian Lynagh committed
750 751
leftDataConName   = conName dATA_EITHER (fsLit "Left")   leftDataConKey
rightDataConName  = conName dATA_EITHER (fsLit "Right")  rightDataConKey
752

753 754 755
-- Generics (types)
v1TyConName, u1TyConName, par1TyConName, rec1TyConName,
  k1TyConName, m1TyConName, sumTyConName, prodTyConName,
756
  compTyConName, rTyConName, pTyConName, dTyConName,
757 758
  cTyConName, sTyConName, rec0TyConName, par0TyConName,
  d1TyConName, c1TyConName, s1TyConName, noSelTyConName,
759
  repTyConName, rep1TyConName :: Name
760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784

v1TyConName  = tcQual gHC_GENERICS (fsLit "V1") v1TyConKey
u1TyConName  = tcQual gHC_GENERICS (fsLit "U1") u1TyConKey
par1TyConName  = tcQual gHC_GENERICS (fsLit "Par1") par1TyConKey
rec1TyConName  = tcQual gHC_GENERICS (fsLit "Rec1") rec1TyConKey
k1TyConName  = tcQual gHC_GENERICS (fsLit "K1") k1TyConKey
m1TyConName  = tcQual gHC_GENERICS (fsLit "M1") m1TyConKey

sumTyConName    = tcQual gHC_GENERICS (fsLit ":+:") sumTyConKey
prodTyConName   = tcQual gHC_GENERICS (fsLit ":*:") prodTyConKey
compTyConName   = tcQual gHC_GENERICS (fsLit ":.:") compTyConKey

rTyConName  = tcQual gHC_GENERICS (fsLit "R") rTyConKey
pTyConName  = tcQual gHC_GENERICS (fsLit "P") pTyConKey
dTyConName  = tcQual gHC_GENERICS (fsLit "D") dTyConKey
cTyConName  = tcQual gHC_GENERICS (fsLit "C") cTyConKey
sTyConName  = tcQual gHC_GENERICS (fsLit "S") sTyConKey

rec0TyConName  = tcQual gHC_GENERICS (fsLit "Rec0") rec0TyConKey
par0TyConName  = tcQual gHC_GENERICS (fsLit "Par0") par0TyConKey
d1TyConName  = tcQual gHC_GENERICS (fsLit "D1") d1TyConKey
c1TyConName  = tcQual gHC_GENERICS (fsLit "C1") c1TyConKey
s1TyConName  = tcQual gHC_GENERICS (fsLit "S1") s1TyConKey
noSelTyConName = tcQual gHC_GENERICS (fsLit "NoSelector") noSelTyConKey

785
repTyConName  = tcQual gHC_GENERICS (fsLit "Rep")  repTyConKey
786 787
rep1TyConName = tcQual gHC_GENERICS (fsLit "Rep1") rep1TyConKey

788
-- Base strings Strings
Ian Lynagh's avatar
Ian Lynagh committed
789
unpackCStringName, unpackCStringFoldrName,
Ian Lynagh's avatar
Ian Lynagh committed
790
    unpackCStringUtf8Name, eqStringName, stringTyConName :: Name
791 792 793
unpackCStringName       = varQual gHC_CSTRING (fsLit "unpackCString#") unpackCStringIdKey
unpackCStringFoldrName  = varQual gHC_CSTRING (fsLit "unpackFoldrCString#") unpackCStringFoldrIdKey
unpackCStringUtf8Name   = varQual gHC_CSTRING (fsLit "unpackCStringUtf8#") unpackCStringUtf8IdKey
794
eqStringName            = varQual gHC_BASE (fsLit "eqString")  eqStringIdKey
Ian Lynagh's avatar
Ian Lynagh committed
795
stringTyConName         = tcQual  gHC_BASE (fsLit "String") stringTyConKey
796

797
-- The 'inline' function
Ian Lynagh's avatar
Ian Lynagh committed
798
inlineIdName :: Name
799
inlineIdName            = varQual gHC_MAGIC (fsLit "inline") inlineIdKey
800

801 802 803 804
-- The 'undefined' function. Used by supercompilation.
undefinedName :: Name
undefinedName = varQual gHC_ERR (fsLit "undefined") undefinedKey

805
-- Base classes (Eq, Ord, Functor)
806
fmapName, eqClassName, eqName, ordClassName, geName, functorClassName :: Name
807 808 809 810
eqClassName       = clsQual  gHC_CLASSES (fsLit "Eq")      eqClassKey
eqName            = methName gHC_CLASSES (fsLit "==")      eqClassOpKey
ordClassName      = clsQual  gHC_CLASSES (fsLit "Ord")     ordClassKey
geName            = methName gHC_CLASSES (fsLit ">=")      geClassOpKey
Ian Lynagh's avatar
Ian Lynagh committed
811
functorClassName  = clsQual  gHC_BASE (fsLit "Functor") functorClassKey
812
fmapName          = methName gHC_BASE (fsLit "fmap")    fmapClassOpKey
813 814

-- Class Monad
Ian Lynagh's avatar
Ian Lynagh committed
815
monadClassName, thenMName, bindMName, returnMName, failMName :: Name
816 817 818 819 820
monadClassName     = clsQual  gHC_BASE (fsLit "Monad")  monadClassKey
thenMName          = methName gHC_BASE (fsLit ">>")     thenMClassOpKey
bindMName          = methName gHC_BASE (fsLit ">>=")    bindMClassOpKey
returnMName        = methName gHC_BASE (fsLit "return") returnMClassOpKey
failMName          = methName gHC_BASE (fsLit "fail")   failMClassOpKey
821

822 823 824 825 826 827
-- Classes (Applicative, Foldable, Traversable)
applicativeClassName, foldableClassName, traversableClassName :: Name
applicativeClassName  = clsQual  cONTROL_APPLICATIVE (fsLit "Applicative") applicativeClassKey
foldableClassName     = clsQual  dATA_FOLDABLE       (fsLit "Foldable")    foldableClassKey
traversableClassName  = clsQual  dATA_TRAVERSABLE    (fsLit "Traversable") traversableClassKey

828
-- Functions for GHC extensions
Ian Lynagh's avatar
Ian Lynagh committed
829
groupWithName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
830
groupWithName = varQual gHC_EXTS (fsLit "groupWith") groupWithIdKey
831

832
-- Random PrelBase functions
Ian Lynagh's avatar
Ian Lynagh committed
833
fromStringName, otherwiseIdName, foldrName, buildName, augmentName,
834
    mapName, appendName, assertName,
Ian Lynagh's avatar
Ian Lynagh committed
835
    breakpointName, breakpointCondName, breakpointAutoName,
836
    dollarName, opaqueTyConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
837 838
fromStringName = methName dATA_STRING (fsLit "fromString") fromStringClassOpKey
otherwiseIdName   = varQual gHC_BASE (fsLit "otherwise")  otherwiseIdKey
839 840 841
foldrName         = varQual gHC_BASE (fsLit "foldr")      foldrIdKey
buildName         = varQual gHC_BASE (fsLit "build")      buildIdKey
augmentName       = varQual gHC_BASE (fsLit "augment")    augmentIdKey
842
mapName           = varQual gHC_BASE (fsLit "map")        mapIdKey
843 844
appendName        = varQual gHC_BASE (fsLit "++")         appendIdKey
dollarName        = varQual gHC_BASE (fsLit "$")          dollarIdKey
Ian Lynagh's avatar
Ian Lynagh committed
845 846 847 848 849
assertName        = varQual gHC_BASE (fsLit "assert")     assertIdKey
breakpointName    = varQual gHC_BASE (fsLit "breakpoint") breakpointIdKey
breakpointCondName= varQual gHC_BASE (fsLit "breakpointCond") breakpointCondIdKey
breakpointAutoName= varQual gHC_BASE (fsLit "breakpointAuto") breakpointAutoIdKey
opaqueTyConName   = tcQual  gHC_BASE (fsLit "Opaque")   opaqueTyConKey
mnislaih's avatar
mnislaih committed
850

Ian Lynagh's avatar
Ian Lynagh committed
851
breakpointJumpName :: Name
852 853 854
breakpointJumpName
    = mkInternalName
        breakpointJumpIdKey
Ian Lynagh's avatar
Ian Lynagh committed
855
        (mkOccNameFS varName (fsLit "breakpointJump"))
856
        noSrcSpan
Ian Lynagh's avatar
Ian Lynagh committed
857
breakpointCondJumpName :: Name
David Himmelstrup's avatar
David Himmelstrup committed
858 859 860
breakpointCondJumpName
    = mkInternalName
        breakpointCondJumpIdKey
Ian Lynagh's avatar
Ian Lynagh committed
861
        (mkOccNameFS varName (fsLit "breakpointCondJump"))
862
        noSrcSpan
Ian Lynagh's avatar
Ian Lynagh committed
863
breakpointAutoJumpName :: Name
mnislaih's avatar
mnislaih committed
864 865 866
breakpointAutoJumpName
    = mkInternalName
        breakpointAutoJumpIdKey
Ian Lynagh's avatar
Ian Lynagh committed
867
        (mkOccNameFS varName (fsLit "breakpointAutoJump"))
868
        noSrcSpan
869

870
-- PrelTup
Ian Lynagh's avatar
Ian Lynagh committed
871
fstName, sndName :: Name
872 873
fstName           = varQual dATA_TUPLE (fsLit "fst") fstIdKey
sndName           = varQual dATA_TUPLE (fsLit "snd") sndIdKey
874

875
-- Module GHC.Num
876
numClassName, fromIntegerName, minusName, negateName :: Name
877
numClassName      = clsQual  gHC_NUM (fsLit "Num") numClassKey
Ian Lynagh's avatar
Ian Lynagh committed
878
fromIntegerName   = methName gHC_NUM (fsLit "fromInteger") fromIntegerClassOpKey
879 880
minusName         = methName gHC_NUM (fsLit "-") minusClassOpKey
negateName        = methName gHC_NUM (fsLit "negate") negateClassOpKey
881

882
integerTyConName, mkIntegerName,
883
    integerToWord64Name, integerToInt64Name,
Ian Lynagh's avatar
Ian Lynagh committed
884
    word64ToIntegerName, int64ToIntegerName,
885
    plusIntegerName, timesIntegerName, smallIntegerName,
886
    wordToIntegerName,
887 888 889 890
    integerToWordName, integerToIntName, minusIntegerName,
    negateIntegerName, eqIntegerName, neqIntegerName,
    absIntegerName, signumIntegerName,
    leIntegerName, gtIntegerName, ltIntegerName, geIntegerName,
Ian Lynagh's avatar
Ian Lynagh committed
891
    compareIntegerName, quotRemIntegerName, divModIntegerName,
892
    quotIntegerName, remIntegerName,
893
    floatFromIntegerName, doubleFromIntegerName,
894
    encodeFloatIntegerName, encodeDoubleIntegerName,
Ian Lynagh's avatar
Ian Lynagh committed
895
    decodeDoubleIntegerName,
896 897 898
    gcdIntegerName, lcmIntegerName,
    andIntegerName, orIntegerName, xorIntegerName, complementIntegerName,
    shiftLIntegerName, shiftRIntegerName :: Name
899 900
integerTyConName      = tcQual  gHC_INTEGER_TYPE (fsLit "Integer")           integerTyConKey
mkIntegerName         = varQual gHC_INTEGER_TYPE (fsLit "mkInteger")         mkIntegerIdKey
901 902
integerToWord64Name   = varQual gHC_INTEGER_TYPE (fsLit "integerToWord64")   integerToWord64IdKey
integerToInt64Name    = varQual gHC_INTEGER_TYPE (fsLit "integerToInt64")    integerToInt64IdKey
Ian Lynagh's avatar
Ian Lynagh committed
903 904
word64ToIntegerName   = varQual gHC_INTEGER_TYPE (fsLit "word64ToInteger")   word64ToIntegerIdKey
int64ToIntegerName    = varQual gHC_INTEGER_TYPE (fsLit "int64ToInteger")    int64ToIntegerIdKey
905 906 907
plusIntegerName       = varQual gHC_INTEGER_TYPE (fsLit "plusInteger")       plusIntegerIdKey
timesIntegerName      = varQual gHC_INTEGER_TYPE (fsLit "timesInteger")      timesIntegerIdKey
smallIntegerName      = varQual gHC_INTEGER_TYPE (fsLit "smallInteger")      smallIntegerIdKey
908
wordToIntegerName     = varQual gHC_INTEGER_TYPE (fsLit "wordToInteger")     wordToIntegerIdKey
909 910 911 912 913 914 915 916 917 918 919 920 921
integerToWordName     = varQual gHC_INTEGER_TYPE (fsLit "integerToWord")     integerToWordIdKey
integerToIntName      = varQual gHC_INTEGER_TYPE (fsLit "integerToInt")      integerToIntIdKey
minusIntegerName      = varQual gHC_INTEGER_TYPE (fsLit "minusInteger")      minusIntegerIdKey
negateIntegerName     = varQual gHC_INTEGER_TYPE (fsLit "negateInteger")     negateIntegerIdKey
eqIntegerName         = varQual gHC_INTEGER_TYPE (fsLit "eqInteger")         eqIntegerIdKey
neqIntegerName        = varQual gHC_INTEGER_TYPE (fsLit "neqInteger")        neqIntegerIdKey
absIntegerName        = varQual gHC_INTEGER_TYPE (fsLit "absInteger")        absIntegerIdKey
signumIntegerName     = varQual gHC_INTEGER_TYPE (fsLit "signumInteger")     signumIntegerIdKey
leIntegerName         = varQual gHC_INTEGER_TYPE (fsLit "leInteger")         leIntegerIdKey
gtIntegerName         = varQual gHC_INTEGER_TYPE (fsLit "gtInteger")         gtIntegerIdKey
ltIntegerName         = varQual gHC_INTEGER_TYPE (fsLit "ltInteger")         ltIntegerIdKey
geIntegerName         = varQual gHC_INTEGER_TYPE (fsLit "geInteger")         geIntegerIdKey
compareIntegerName    = varQual gHC_INTEGER_TYPE (fsLit "compareInteger")    compareIntegerIdKey
Ian Lynagh's avatar
Ian Lynagh committed
922 923
quotRemIntegerName    = varQual gHC_INTEGER_TYPE (fsLit "quotRemInteger")    quotRemIntegerIdKey
divModIntegerName     = varQual gHC_INTEGER_TYPE (fsLit "divModInteger")     divModIntegerIdKey
924 925
quotIntegerName       = varQual gHC_INTEGER_TYPE (fsLit "quotInteger")       quotIntegerIdKey
remIntegerName        = varQual gHC_INTEGER_TYPE (fsLit "remInteger")        remIntegerIdKey
926 927 928 929
floatFromIntegerName  = varQual gHC_INTEGER_TYPE (fsLit "floatFromInteger")      floatFromIntegerIdKey
doubleFromIntegerName = varQual gHC_INTEGER_TYPE (fsLit "doubleFromInteger")     doubleFromIntegerIdKey
encodeFloatIntegerName  = varQual gHC_INTEGER_TYPE (fsLit "encodeFloatInteger")  encodeFloatIntegerIdKey
encodeDoubleIntegerName = varQual gHC_INTEGER_TYPE (fsLit "encodeDoubleInteger") encodeDoubleIntegerIdKey
Ian Lynagh's avatar
Ian Lynagh committed
930
decodeDoubleIntegerName = varQual gHC_INTEGER_TYPE (fsLit "decodeDoubleInteger") decodeDoubleIntegerIdKey
931 932 933 934 935 936 937 938
gcdIntegerName        = varQual gHC_INTEGER_TYPE (fsLit "gcdInteger")        gcdIntegerIdKey
lcmIntegerName        = varQual gHC_INTEGER_TYPE (fsLit "lcmInteger")        lcmIntegerIdKey
andIntegerName        = varQual gHC_INTEGER_TYPE (fsLit "andInteger")        andIntegerIdKey
orIntegerName         = varQual gHC_INTEGER_TYPE (fsLit "orInteger")         orIntegerIdKey
xorIntegerName        = varQual gHC_INTEGER_TYPE (fsLit "xorInteger")        xorIntegerIdKey
complementIntegerName = varQual gHC_INTEGER_TYPE (fsLit "complementInteger") complementIntegerIdKey
shiftLIntegerName     = varQual gHC_INTEGER_TYPE (fsLit "shiftLInteger")     shiftLIntegerIdKey
shiftRIntegerName     = varQual gHC_INTEGER_TYPE (fsLit "shiftRInteger")     shiftRIntegerIdKey
939

940
-- GHC.Real types and classes
Ian Lynagh's avatar
Ian Lynagh committed
941 942
rationalTyConName, ratioTyConName, ratioDataConName, realClassName,
    integralClassName, realFracClassName, fractionalClassName,
943 944
    fromRationalName, toIntegerName, toRationalName, fromIntegralName,
    realToFracName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
945
rationalTyConName   = tcQual  gHC_REAL (fsLit "Rational") rationalTyConKey
946
ratioTyConName      = tcQual  gHC_REAL (fsLit "Ratio") ratioTyConKey
Ian Lynagh's avatar
Ian Lynagh committed
947
ratioDataConName    = conName gHC_REAL (fsLit ":%") ratioDataConKey
948
realClassName       = clsQual gHC_REAL (fsLit "Real") realClassKey
Ian Lynagh's avatar
Ian Lynagh committed
949 950 951
integralClassName   = clsQual gHC_REAL (fsLit "Integral") integralClassKey
realFracClassName   = clsQual gHC_REAL (fsLit "RealFrac") realFracClassKey
fractionalClassName = clsQual gHC_REAL (fsLit "Fractional") fractionalClassKey
952 953 954 955 956
fromRationalName    = methName gHC_REAL (fsLit "fromRational") fromRationalClassOpKey
toIntegerName       = methName gHC_REAL (fsLit "toInteger") toIntegerClassOpKey
toRationalName      = methName gHC_REAL (fsLit "toRational") toRationalClassOpKey
fromIntegralName    = varQual  gHC_REAL (fsLit "fromIntegral") fromIntegralIdKey
realToFracName      = varQual  gHC_REAL (fsLit "realToFrac") realToFracIdKey
957 958

-- PrelFloat classes
Ian Lynagh's avatar
Ian Lynagh committed
959
floatingClassName, realFloatClassName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
960 961
floatingClassName  = clsQual  gHC_FLOAT (fsLit "Floating") floatingClassKey
realFloatClassName = clsQual  gHC_FLOAT (fsLit "RealFloat") realFloatClassKey
962

963 964 965 966 967
-- other GHC.Float functions
rationalToFloatName, rationalToDoubleName :: Name
rationalToFloatName  = varQual gHC_FLOAT (fsLit "rationalToFloat") rationalToFloatIdKey
rationalToDoubleName = varQual gHC_FLOAT (fsLit "rationalToDouble") rationalToDoubleIdKey

968
-- Class Ix
Ian Lynagh's avatar
Ian Lynagh committed
969
ixClassName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
970
ixClassName = clsQual gHC_ARR (fsLit "Ix") ixClassKey
971

972
-- Class Typeable
973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990
typeableClassName,
    oldTypeableClassName, oldTypeable1ClassName, oldTypeable2ClassName,
    oldTypeable3ClassName, oldTypeable4ClassName, oldTypeable5ClassName,
    oldTypeable6ClassName, oldTypeable7ClassName :: Name
typeableClassName  = clsQual tYPEABLE_INTERNAL (fsLit "Typeable")  typeableClassKey
oldTypeableClassName  = clsQual oLDTYPEABLE_INTERNAL (fsLit "Typeable")  oldTypeableClassKey
oldTypeable1ClassName = clsQual oLDTYPEABLE_INTERNAL (fsLit "Typeable1") oldTypeable1ClassKey
oldTypeable2ClassName = clsQual oLDTYPEABLE_INTERNAL (fsLit "Typeable2") oldTypeable2ClassKey
oldTypeable3ClassName = clsQual oLDTYPEABLE_INTERNAL (fsLit "Typeable3") oldTypeable3ClassKey
oldTypeable4ClassName = clsQual oLDTYPEABLE_INTERNAL (fsLit "Typeable4") oldTypeable4ClassKey
oldTypeable5ClassName = clsQual oLDTYPEABLE_INTERNAL (fsLit "Typeable5") oldTypeable5ClassKey
oldTypeable6ClassName = clsQual oLDTYPEABLE_INTERNAL (fsLit "Typeable6") oldTypeable6ClassKey
oldTypeable7ClassName = clsQual oLDTYPEABLE_INTERNAL (fsLit "Typeable7") oldTypeable7ClassKey

oldTypeableClassNames :: [Name]
oldTypeableClassNames = [ oldTypeableClassName, oldTypeable1ClassName, oldTypeable2ClassName
                        , oldTypeable3ClassName, oldTypeable4ClassName, oldTypeable5ClassName
                        , oldTypeable6ClassName, oldTypeable7ClassName ]
991 992

-- Class Data
Ian Lynagh's avatar
Ian Lynagh committed
993
dataClassName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
994
dataClassName = clsQual gENERICS (fsLit "Data") dataClassKey
995 996

-- Error module
Ian Lynagh's avatar
Ian Lynagh committed
997
assertErrorName    :: Name
998
assertErrorName   = varQual gHC_IO_Exception (fsLit "assertError") assertErrorIdKey
999

1000
-- Enum module (Enum, Bounded)
Ian Lynagh's avatar
Ian Lynagh committed
1001 1002
enumClassName, enumFromName, enumFromToName, enumFromThenName,
    enumFromThenToName, boundedClassName :: Name
1003 1004 1005
enumClassName      = clsQual gHC_ENUM (fsLit "Enum") enumClassKey
enumFromName       = methName gHC_ENUM (fsLit "enumFrom") enumFromClassOpKey
enumFromToName     = methName gHC_ENUM (fsLit "enumFromTo") enumFromToClassOpKey
Ian Lynagh's avatar
Ian Lynagh committed
1006 1007 1008
enumFromThenName   = methName gHC_ENUM (fsLit "enumFromThen") enumFromThenClassOpKey
enumFromThenToName = methName gHC_ENUM (fsLit "enumFromThenTo") enumFromThenToClassOpKey
boundedClassName   = clsQual gHC_ENUM (fsLit "Bounded") boundedClassKey
1009 1010

-- List functions
Ian Lynagh's avatar
Ian Lynagh committed
1011
concatName, filterName, zipName :: Name
1012 1013 1014
concatName        = varQual gHC_LIST (fsLit "concat") concatIdKey
filterName        = varQual gHC_LIST (fsLit "filter") filterIdKey
zipName           = varQual gHC_LIST (fsLit "zip") zipIdKey
1015

1016 1017 1018 1019 1020 1021 1022
-- Overloaded lists
isListClassName, fromListName, fromListNName, toListName :: Name
isListClassName = clsQual gHC_EXTS (fsLit "IsList") isListClassKey
fromListName = methName gHC_EXTS (fsLit "fromList") fromListClassOpKey
fromListNName = methName gHC_EXTS (fsLit "fromListN") fromListNClassOpKey
toListName = methName gHC_EXTS (fsLit "toList") toListClassOpKey

1023
-- Class Show
Ian Lynagh's avatar
Ian Lynagh committed
1024
showClassName :: Name
1025
showClassName     = clsQual gHC_SHOW (fsLit "Show")       showClassKey
1026 1027

-- Class Read
Ian Lynagh's avatar
Ian Lynagh committed
1028
readClassName :: Name
1029
readClassName      = clsQual gHC_READ (fsLit "Read") readClassKey
1030

1031 1032
-- Classes Generic and Generic1, Datatype, Constructor and Selector
genClassName, gen1ClassName, datatypeClassName, constructorClassName,
1033
  selectorClassName :: Name
1034 1035
genClassName  = clsQual gHC_GENERICS (fsLit "Generic")  genClassKey
gen1ClassName = clsQual gHC_GENERICS (fsLit "Generic1") gen1ClassKey
1036 1037 1038 1039 1040

datatypeClassName = clsQual gHC_GENERICS (fsLit "Datatype") datatypeClassKey
constructorClassName = clsQual gHC_GENERICS (fsLit "Constructor") constructorClassKey
selectorClassName = clsQual gHC_GENERICS (fsLit "Selector") selectorClassKey

dterei's avatar
dterei committed
1041 1042 1043 1044 1045
-- GHCi things
ghciIoClassName, ghciStepIoMName :: Name
ghciIoClassName = clsQual gHC_GHCI (fsLit "GHCiSandboxIO") ghciIoClassKey
ghciStepIoMName = methName gHC_GHCI (fsLit "ghciStepIO") ghciStepIoMClassOpKey

1046
-- IO things
1047 1048 1049 1050 1051 1052 1053 1054
ioTyConName, ioDataConName, thenIOName, bindIOName, returnIOName,
    failIOName :: Name
ioTyConName       = tcQual  gHC_TYPES (fsLit "IO") ioTyConKey
ioDataConName     = conName gHC_TYPES (fsLit "IO") ioDataConKey
thenIOName        = varQual gHC_BASE (fsLit "thenIO") thenIOIdKey
bindIOName        = varQual gHC_BASE (fsLit "bindIO") bindIOIdKey
returnIOName      = varQual gHC_BASE (fsLit "returnIO") returnIOIdKey
failIOName        = varQual gHC_IO (fsLit "failIO") failIOIdKey
1055

1056
-- IO things
Ian Lynagh's avatar
Ian Lynagh committed
1057
printName :: Name
1058
printName         = varQual sYSTEM_IO (fsLit "print") printIdKey
1059

1060
-- Int, Word, and Addr things
Ian Lynagh's avatar
Ian Lynagh committed
1061
int8TyConName, int16TyConName, int32TyConName, int64TyConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
1062 1063 1064 1065
int8TyConName     = tcQual gHC_INT  (fsLit "Int8") int8TyConKey
int16TyConName    = tcQual gHC_INT  (fsLit "Int16") int16TyConKey
int32TyConName    = tcQual gHC_INT  (fsLit "Int32") int32TyConKey
int64TyConName    = tcQual gHC_INT  (fsLit "Int64") int64TyConKey
1066

1067
-- Word module
Ian Lynagh's avatar
Ian Lynagh committed
1068 1069
word8TyConName, word16TyConName, word32TyConName, word64TyConName,
    wordTyConName, wordDataConName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
1070 1071 1072 1073
word8TyConName    = tcQual  gHC_WORD (fsLit "Word8")  word8TyConKey
word16TyConName   = tcQual  gHC_WORD (fsLit "Word16") word16TyConKey
word32TyConName   = tcQual  gHC_WORD (fsLit "Word32") word32TyConKey
word64TyConName   = tcQual  gHC_WORD (fsLit "Word64") word64TyConKey
1074 1075
wordTyConName     = tcQual  gHC_TYPES (fsLit "Word")   wordTyConKey
wordDataConName   = conName gHC_TYPES (fsLit "W#") wordDataConKey
1076

1077
-- PrelPtr module
Ian Lynagh's avatar
Ian Lynagh committed
1078
ptrTyConName, funPtrTyConName :: Name
1079 1080
ptrTyConName      = tcQual   gHC_PTR (fsLit "Ptr") ptrTyConKey
funPtrTyConName   = tcQual   gHC_PTR (fsLit "FunPtr") funPtrTyConKey
1081

1082
-- Foreign objects and weak pointers
Ian Lynagh's avatar
Ian Lynagh committed
1083
stablePtrTyConName, newStablePtrName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
1084 1085
stablePtrTyConName    = tcQual   gHC_STABLE (fsLit "StablePtr") stablePtrTyConKey
newStablePtrName      = varQual  gHC_STABLE (fsLit "newStablePtr") newStablePtrIdKey
1086 1087

-- PrelST module
Ian Lynagh's avatar
Ian Lynagh committed
1088
runSTRepName :: Name
1089
runSTRepName       = varQual gHC_ST  (fsLit "runSTRep") runSTRepIdKey
1090

1091
-- Recursive-do notation
Ian Lynagh's avatar
Ian Lynagh committed
1092
monadFixClassName, mfixName :: Name
Ian Lynagh's avatar
Ian Lynagh committed
1093
monadFixClassName  = clsQual mONAD_FIX (fsLit "MonadFix") monadFixClassKey
1094
mfixName           = methName mONAD_FIX (fsLit "mfix") mfixIdKey
sof's avatar
sof committed