summaryrefslogtreecommitdiff
path: root/compiler/prelude
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2018-06-07 13:30:28 -0400
committerBen Gamari <ben@smart-cactus.org>2018-06-07 18:06:30 -0400
commit5926b6ed0dcc86f8fd6038fdcc5e2ba2856f40ce (patch)
tree9e35b564dfb8039fe7b8139a84c0a2283f00fc7f /compiler/prelude
parent04e29fc63e1f1d975c73449b27471cf59c9ffca2 (diff)
downloadhaskell-5926b6ed0dcc86f8fd6038fdcc5e2ba2856f40ce.tar.gz
Don't expose (~#), (~R#), (~P#) from GHC.Prim
Currently, the primitive `(~#)`, `(~R#)`, and `(~P#)` type constructors are wired in to be exported from `GHC.Prim`. This has some unfortunate consequences, however. It turns out that `(~#)` is actually a legal infix identifier, so users can make use of unboxed equalities in strange ways in user code (see #15209). The other two, `(~R#)` and `(~P#)`, can't be used in source code, but they can be observed with GHCi's `:browse` command, which is somewhat unnerving. The fix for both of these problems is simple: just don't wire them to be exported from `GHC.Prim`. Test Plan: make test TEST="T12023 T15209" Reviewers: bgamari, dfeuer Reviewed By: bgamari, dfeuer Subscribers: rwbarton, thomie, carter, dfeuer GHC Trac Issues: #12023, #15209 Differential Revision: https://phabricator.haskell.org/D4801
Diffstat (limited to 'compiler/prelude')
-rw-r--r--compiler/prelude/PrelInfo.hs2
-rw-r--r--compiler/prelude/TysPrim.hs22
2 files changed, 18 insertions, 6 deletions
diff --git a/compiler/prelude/PrelInfo.hs b/compiler/prelude/PrelInfo.hs
index 8d1f140ca2..2a5fad6733 100644
--- a/compiler/prelude/PrelInfo.hs
+++ b/compiler/prelude/PrelInfo.hs
@@ -252,7 +252,7 @@ ghcPrimExports
= map (avail . idName) ghcPrimIds ++
map (avail . idName . primOpId) allThePrimOps ++
[ AvailTC n [n] []
- | tc <- funTyCon : primTyCons, let n = tyConName tc ]
+ | tc <- funTyCon : exposedPrimTyCons, let n = tyConName tc ]
{-
************************************************************************
diff --git a/compiler/prelude/TysPrim.hs b/compiler/prelude/TysPrim.hs
index f7a51a535e..ff61878964 100644
--- a/compiler/prelude/TysPrim.hs
+++ b/compiler/prelude/TysPrim.hs
@@ -30,7 +30,7 @@ module TysPrim(
tYPE, primRepToRuntimeRep,
funTyCon, funTyConName,
- primTyCons,
+ unexposedPrimTyCons, exposedPrimTyCons, primTyCons,
charPrimTyCon, charPrimTy, charPrimTyConName,
intPrimTyCon, intPrimTy, intPrimTyConName,
@@ -118,7 +118,22 @@ import Data.Char
-}
primTyCons :: [TyCon]
-primTyCons
+primTyCons = unexposedPrimTyCons ++ exposedPrimTyCons
+
+-- | Primitive 'TyCon's that are defined in "GHC.Prim" but not exposed.
+-- It's important to keep these separate as we don't want users to be able to
+-- write them (see Trac #15209) or see them in GHCi's @:browse@ output
+-- (see Trac #12023).
+unexposedPrimTyCons :: [TyCon]
+unexposedPrimTyCons
+ = [ eqPrimTyCon
+ , eqReprPrimTyCon
+ , eqPhantPrimTyCon
+ ]
+
+-- | Primitive 'TyCon's that are defined in, and exported from, "GHC.Prim".
+exposedPrimTyCons :: [TyCon]
+exposedPrimTyCons
= [ addrPrimTyCon
, arrayPrimTyCon
, byteArrayPrimTyCon
@@ -150,9 +165,6 @@ primTyCons
, wordPrimTyCon
, word32PrimTyCon
, word64PrimTyCon
- , eqPrimTyCon
- , eqReprPrimTyCon
- , eqPhantPrimTyCon
, tYPETyCon