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>
Thu, 24 Mar 2016 22:02:02 +0000 (23:02 +0100)
commit17f88142bce386ff99b5130c621f09ade4c909d2
tree1ca63a8dde0586ac9876ddc7dc5458bfae3dba9c
parent0d87eb5ee849fd434910ca20c06edaaf61e9db07
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

(cherry picked from commit 4d791b4f77975422df38f6b43084008edd097f1b)
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