summaryrefslogtreecommitdiff
path: root/compiler/prelude
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2015-06-12 13:15:18 +0100
committerSimon Marlow <marlowsd@gmail.com>2015-06-12 13:15:18 +0100
commitd20031d4c88b256cdae264cb05d9d850e973d956 (patch)
tree84af3e055d60d87058cfe48a7260e75859f9fefe /compiler/prelude
parentc14bd01756ffaf3a0bf34c766cfc1d611dba0dc4 (diff)
downloadhaskell-d20031d4c88b256cdae264cb05d9d850e973d956.tar.gz
Add parseExpr and compileParsedExpr and use them in GHC API and GHCi
Summary: This commit brings following changes and fixes: * Implement parseExpr and compileParsedExpr; * Fix compileExpr and dynCompilerExpr, which returned `()` for empty expr; * Fix :def and :cmd, which didn't work if `IO` or `String` is not in scope; * Use GHCiMonad instead IO in :def and :cmd; * Clean PrelInfo: delete dead comment and duplicate entries, add assertion. See new tests for more details. Test Plan: ./validate Reviewers: austin, dterei, simonmar Reviewed By: simonmar Subscribers: thomie, bgamari Differential Revision: https://phabricator.haskell.org/D974 GHC Trac Issues: #10508
Diffstat (limited to 'compiler/prelude')
-rw-r--r--compiler/prelude/PrelInfo.hs19
-rw-r--r--compiler/prelude/PrelNames.hs23
2 files changed, 24 insertions, 18 deletions
diff --git a/compiler/prelude/PrelInfo.hs b/compiler/prelude/PrelInfo.hs
index 4d1cd9af95..5ab060e941 100644
--- a/compiler/prelude/PrelInfo.hs
+++ b/compiler/prelude/PrelInfo.hs
@@ -36,6 +36,8 @@ import TysWiredIn
import HscTypes
import Class
import TyCon
+import Outputable
+import UniqFM
import Util
import {-# SOURCE #-} TcTypeNats ( typeNatTyCons )
@@ -53,13 +55,20 @@ import Data.Array
********************************************************************* -}
knownKeyNames :: [Name]
-knownKeyNames
- = map getName wiredInThings
- ++ cTupleTyConNames
- ++ basicKnownKeyNames
+knownKeyNames =
+ ASSERT2( isNullUFM badNamesUFM, text "badknownKeyNames" <+> ppr badNamesUFM )
+ names
+ where
+ badNamesUFM = filterUFM (\ns -> length ns > 1) namesUFM
+ namesUFM = foldl (\m n -> addToUFM_Acc (:) singleton m n n) emptyUFM names
+ names = concat
+ [ map getName wiredInThings
+ , cTupleTyConNames
+ , basicKnownKeyNames
#ifdef GHCI
- ++ templateHaskellNames
+ , templateHaskellNames
#endif
+ ]
{- *********************************************************************
* *
diff --git a/compiler/prelude/PrelNames.hs b/compiler/prelude/PrelNames.hs
index ded9583c62..8b60088666 100644
--- a/compiler/prelude/PrelNames.hs
+++ b/compiler/prelude/PrelNames.hs
@@ -170,12 +170,6 @@ isUnboundName name = name `hasKey` unboundKey
This section tells what the compiler knows about the association of
names with uniques. These ones are the *non* wired-in ones. The
wired in ones are defined in TysWiredIn etc.
-
-The names for DPH can come from one of multiple backend packages. At the point where
-'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.
-}
basicKnownKeyNames :: [Name]
@@ -188,7 +182,6 @@ basicKnownKeyNames
stringTyConName,
ratioDataConName,
ratioTyConName,
- integerTyConName,
-- Classes. *Must* include:
-- classes that are grabbed by key (e.g., eqClassKey)
@@ -221,6 +214,8 @@ basicKnownKeyNames
mkAppTyName,
typeLitTypeRepName,
+ -- Dynamic
+ toDynName,
-- Numeric stuff
negateName, minusName, geName, eqName,
@@ -247,8 +242,8 @@ basicKnownKeyNames
fmapName,
joinMName,
- -- MonadRec stuff
- mfixName,
+ -- MonadFix
+ monadFixClassName, mfixName,
-- Arrow stuff
arrAName, composeAName, firstAName,
@@ -318,9 +313,6 @@ basicKnownKeyNames
rationalToFloatName,
rationalToDoubleName,
- -- MonadFix
- monadFixClassName, mfixName,
-
-- Other classes
randomClassName, randomGenClassName, monadPlusClassName,
@@ -1038,7 +1030,9 @@ mkPolyTyConAppName = varQual tYPEABLE_INTERNAL (fsLit "mkPolyTyConApp") mkPol
mkAppTyName = varQual tYPEABLE_INTERNAL (fsLit "mkAppTy") mkAppTyKey
typeLitTypeRepName = varQual tYPEABLE_INTERNAL (fsLit "typeLitTypeRep") typeLitTypeRepKey
-
+-- Dynamic
+toDynName :: Name
+toDynName = varQual dYNAMIC (fsLit "toDyn") toDynIdKey
-- Class Data
dataClassName :: Name
@@ -1887,6 +1881,9 @@ mkPolyTyConAppKey = mkPreludeMiscIdUnique 504
mkAppTyKey = mkPreludeMiscIdUnique 505
typeLitTypeRepKey = mkPreludeMiscIdUnique 506
+-- Dynamic
+toDynIdKey :: Unique
+toDynIdKey = mkPreludeMiscIdUnique 507
{-
************************************************************************