[commit: ghc] master: Add 'DeBruijn' constructor, which generalizes "key modulo alpha-renaming." (ccef014)
git at git.haskell.org
git at git.haskell.org
Thu Jan 8 22:06:35 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/ccef01465366e11978fdad1bf28aeac2edde36c2/ghc
>---------------------------------------------------------------
commit ccef01465366e11978fdad1bf28aeac2edde36c2
Author: Edward Z. Yang <ezyang at cs.stanford.edu>
Date: Wed Jan 7 17:50:42 2015 -0800
Add 'DeBruijn' constructor, which generalizes "key modulo alpha-renaming."
Summary:
We need equality over Types, etc; and this equality has to be modulo alpha
renaming. Previously, we baked CmEnv into the generic "empty, singleton, many"
structure. This isn't great, really GenMap should be more generic than that.
The insight: we've defined the key wrong: the key should be *equipped*
with the alpha-renaming information (CmEnv) and a TrieMap queried with this.
This is what the DeBruijn constructor does.
Now, when we define TrieMap instances, we don't have to synthesize an emptyCME
to pass to the helper functions: we have all the information we need. To make a
recursive call, we construct a new DeBruijn with the updated CME and then
call lookupTM on that. We can even define a plain old Eq instance on DeBruijn
respecting alpha-renaming. There are number of other good knock-on effects.
This patch does add a bit of boxing and unboxing, but nothing the optimizer
shouldn't be able to eliminate.
Signed-off-by: Edward Z. Yang <ezyang at cs.stanford.edu>
Test Plan: validate
Reviewers: simonpj, austin
Subscribers: carter, thomie
Differential Revision: https://phabricator.haskell.org/D608
GHC Trac Issues: #9960
>---------------------------------------------------------------
ccef01465366e11978fdad1bf28aeac2edde36c2
compiler/coreSyn/TrieMap.hs | 213 ++++++++++++++++++++---------------------
compiler/typecheck/TcSMonad.hs | 11 ++-
2 files changed, 110 insertions(+), 114 deletions(-)
Diff suppressed because of size. To see it, use:
git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc ccef01465366e11978fdad1bf28aeac2edde36c2
More information about the ghc-commits
mailing list