diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2016-07-20 12:34:54 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-07-20 15:58:02 +0200 |
commit | 9513fe6bdeafd35ca1a04e17b5f94732516766aa (patch) | |
tree | 7a18f5beb24e31e1b0af71d2450f9228685e6ad5 /compiler/typecheck/TcTypeable.hs | |
parent | ed4809813fa51524ae73a4475afe33018a67f87d (diff) | |
download | haskell-9513fe6bdeafd35ca1a04e17b5f94732516766aa.tar.gz |
Clean up interaction between name cache and built-in syntax
This cleans up various aspects of the handling of built-in syntax in the
original name cache (hopefully resulting in a nice reduction in compiler
allocations),
* Remove tuple types from original name cache: There is really no
reason for these to be in the name cache since we already handle
them specially in interface files to ensure that we can resolve them
directly to Names, avoiding extraneous name cache lookups.
* Sadly it's not possible to remove all traces of tuples from the
name cache, however. Namely we need to keep the tuple type
representations in since otherwise they would need to be wired-in
* Remove the special cases for (:), [], and (##) in isBuiltInOcc_maybe
and rename it to isTupleOcc_maybe
* Split lookupOrigNameCache into two variants,
* lookupOrigNameCache': Merely looks up an OccName in the original
name cache, making no attempt to resolve tuples
* lookupOrigNameCache: Like the above but handles tuples as well.
This is given the un-primed name since it does the "obvious"
thing from the perspective of an API user, who knows nothing of
our special treatment of tuples.
Arriving at this design took a significant amount of iteration. The
trail of debris leading here can be found in #11357.
Thanks to ezyang and Simon for all of their help in coming to this
solution.
Test Plan: Validate
Reviewers: goldfire, simonpj, austin
Reviewed By: simonpj
Subscribers: thomie, ezyang
Differential Revision: https://phabricator.haskell.org/D2414
GHC Trac Issues: #11357
Diffstat (limited to 'compiler/typecheck/TcTypeable.hs')
-rw-r--r-- | compiler/typecheck/TcTypeable.hs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/compiler/typecheck/TcTypeable.hs b/compiler/typecheck/TcTypeable.hs index 04d07d16eb..a733a3263b 100644 --- a/compiler/typecheck/TcTypeable.hs +++ b/compiler/typecheck/TcTypeable.hs @@ -85,6 +85,25 @@ There are many wrinkles: representations for TyCon and Module. See GHC.Types Note [Runtime representation of modules and tycons] + +Note [Tuples and Typeable] +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Tuples are generally special in GHC since they are not placed in the original +name cache (see Note [Built-in syntax and the OrigNameCache]). This poses a +problem for Typeable: we need to serialize the Name of a type representation for +a tuple type with enough information such that the compiler will realize that +the Name is that of a tuple type representation (and thus gets the same unique +as is indicated in the wired-in TyCon) when it is loaded from an interface file. + +We ensure this by only including the type representations for the type +contructor and its promoted data constructor in the original name cache. The +alternative would have been to use the same special interface file encoding as +we use for tuple TyCons for tuple type representations. Unfortunately, this is +rather tiresome to do so we are going to live with this compromise for now. + +A great deal of discussion on how we came to this design can be found in #12357. + -} -- | Generate the Typeable bindings for a module. This is the only |