summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorRyanGlScott <ryan.gl.scott@gmail.com>2015-10-13 00:43:32 -0500
committerAustin Seipp <austin@well-typed.com>2015-10-13 00:43:42 -0500
commitd2f9972a35ce05ceb8a78893e433ef1df06f73ef (patch)
treebc3cee0ec99aacd64298993fde590c017734c6e6 /compiler
parent94ef79a766a1f58a5daadcf7dbb342812cd1a9bd (diff)
downloadhaskell-d2f9972a35ce05ceb8a78893e433ef1df06f73ef.tar.gz
Make dataToQa aware of Data instances which use functions to implement toConstr
Trac #10796 exposes a way to make `template-haskell`'s `dataToQa` function freak out if using a `Data` instance that produces a `Constr` (by means of `toConstr`) using a function name instead of a data constructor name. While such `Data` instances are somewhat questionable, they are nevertheless present in popular libraries (e.g., `containers`), so we can at least make `dataToQa` aware of their existence. In order to properly distinguish strings which represent variables (as opposed to data constructors), it was necessary to move functionality from `Lexeme` (in `ghc`) to `GHC.Lexeme` in a new `ghc-boot` library (which was previously named `bin-package-db`). Reviewed By: goldfire, thomie Differential Revision: https://phabricator.haskell.org/D1313 GHC Trac Issues: #10796
Diffstat (limited to 'compiler')
-rw-r--r--compiler/basicTypes/Lexeme.hs26
-rw-r--r--compiler/ghc.cabal.in2
-rw-r--r--compiler/main/PackageConfig.hs2
3 files changed, 8 insertions, 22 deletions
diff --git a/compiler/basicTypes/Lexeme.hs b/compiler/basicTypes/Lexeme.hs
index a2409614d1..2049e001bf 100644
--- a/compiler/basicTypes/Lexeme.hs
+++ b/compiler/basicTypes/Lexeme.hs
@@ -6,11 +6,11 @@
module Lexeme (
-- * Lexical characteristics of Haskell names
-
+
-- | Use these functions to figure what kind of name a 'FastString'
-- represents; these functions do /not/ check that the identifier
-- is valid.
-
+
isLexCon, isLexVar, isLexId, isLexSym,
isLexConId, isLexConSym, isLexVarId, isLexVarSym,
startsVarSym, startsVarId, startsConSym, startsConId,
@@ -33,6 +33,8 @@ import Util ((<||>))
import Data.Char
import qualified Data.Set as Set
+import GHC.Lexeme
+
{-
************************************************************************
@@ -86,22 +88,6 @@ isLexVarSym fs -- Infix identifiers e.g. "+"
(c:cs) -> startsVarSym c && all isVarSymChar cs
-- See Note [Classification of generated names]
--------------
-startsVarSym, startsVarId, startsConSym, startsConId :: Char -> Bool
-startsVarSym c = startsVarSymASCII c || (ord c > 0x7f && isSymbol c) -- Infix Ids
-startsConSym c = c == ':' -- Infix data constructors
-startsVarId c = c == '_' || case generalCategory c of -- Ordinary Ids
- LowercaseLetter -> True
- OtherLetter -> True -- See #1103
- _ -> False
-startsConId c = isUpper c || c == '(' -- Ordinary type constructors and data constructors
-
-startsVarSymASCII :: Char -> Bool
-startsVarSymASCII c = c `elem` "!#$%&*+./<=>?@\\^|~-"
-
-isVarSymChar :: Char -> Bool
-isVarSymChar c = c == ':' || startsVarSym c
-
{-
************************************************************************
@@ -113,7 +99,7 @@ isVarSymChar c = c == ':' || startsVarSym c
-}
----------------------
--- External interface
+-- External interface
----------------------
-- | Is this an acceptable variable name?
@@ -237,7 +223,7 @@ okSymChar c
ModifierSymbol -> True
OtherSymbol -> True
_ -> False
-
+
-- | All reserved identifiers. Taken from section 2.4 of the 2010 Report.
reservedIds :: Set.Set String
reservedIds = Set.fromList [ "case", "class", "data", "default", "deriving"
diff --git a/compiler/ghc.cabal.in b/compiler/ghc.cabal.in
index 37a4f281d6..f068eb2458 100644
--- a/compiler/ghc.cabal.in
+++ b/compiler/ghc.cabal.in
@@ -55,7 +55,7 @@ Library
template-haskell,
hpc,
transformers,
- bin-package-db,
+ ghc-boot,
hoopl
if os(windows)
diff --git a/compiler/main/PackageConfig.hs b/compiler/main/PackageConfig.hs
index f3cdac77da..9e9775bc04 100644
--- a/compiler/main/PackageConfig.hs
+++ b/compiler/main/PackageConfig.hs
@@ -37,7 +37,7 @@ import Module
import Unique
-- -----------------------------------------------------------------------------
--- Our PackageConfig type is the InstalledPackageInfo from bin-package-db,
+-- Our PackageConfig type is the InstalledPackageInfo from ghc-boot,
-- which is similar to a subset of the InstalledPackageInfo type from Cabal.
type PackageConfig = InstalledPackageInfo