Simplify: Make generated names more useful
authorBen Gamari <bgamari.foss@gmail.com>
Fri, 11 Mar 2016 14:24:49 +0000 (15:24 +0100)
committerBen Gamari <ben@smart-cactus.org>
Sat, 12 Mar 2016 11:03:19 +0000 (12:03 +0100)
commit4d791b4f77975422df38f6b43084008edd097f1b
tree327edc081c24a62309a88aa2db4f6c407eb12700
parente46742f5c51938bc7c992ac37fecc6df8cab7647
Simplify: Make generated names more useful

makeTrivial is responsible for concocting names during simplification.
Previously, however, it would make no attempt to generate a name that
might be useful to later readers of the resulting Core. Here we add a
bit of state to SimplEnv: a finite depth stack of binders within which
we are currently simplifying. We then derive generated binders from this
context.

See #11676.

Open questions:
  * Is there a better way to accomplish this?
  * Is `maxContextDepth` too large/small?

Test Plan: Validate, look at Core.

Reviewers: austin, simonpj

Reviewed By: simonpj

Subscribers: thomie, simonpj

Differential Revision: https://phabricator.haskell.org/D1970

GHC Trac Issues: #11676
13 files changed:
compiler/simplCore/Simplify.hs
testsuite/tests/deSugar/should_compile/T2431.stderr
testsuite/tests/ghci.debugger/scripts/break009.stdout
testsuite/tests/ghci.debugger/scripts/break010.stdout
testsuite/tests/ghci.debugger/scripts/break011.stdout
testsuite/tests/ghci.debugger/scripts/break012.stdout
testsuite/tests/ghci.debugger/scripts/break028.stdout
testsuite/tests/ghci.debugger/scripts/print018.stdout
testsuite/tests/ghci.debugger/scripts/print031.stdout
testsuite/tests/roles/should_compile/Roles13.stderr
testsuite/tests/simplCore/should_compile/EvalTest.stdout
testsuite/tests/simplCore/should_compile/T9400.stderr
testsuite/tests/simplCore/should_compile/spec-inline.stderr