Fix 'SPECIALISE instance'
authorSimon Peyton Jones <simonpj@microsoft.com>
Wed, 21 Dec 2016 12:24:41 +0000 (12:24 +0000)
committerSimon Peyton Jones <simonpj@microsoft.com>
Wed, 21 Dec 2016 12:26:24 +0000 (12:26 +0000)
commit1a4c04b13a695a530ee24835a7550a8c9ed2d37a
tree6bec42a3a6538d8e26985f4929f49bf257bbf814
parentc48595eef2bca6d91ec0a649839f8066f269e6a4
Fix 'SPECIALISE instance'

Trac #12944 showed that the DsBinds code that implemented a
SPECIALISE pragma was inadequate if the constraints solving
added let-bindings for dictionaries.  The result was that
we ended up with an unbound dictionary in a DFunUnfolding -- and
Lint didn't even check for that!

Fixing this was not entirely straightforward

* In DsBinds.dsSpec we use a new function
     TcEvidence.collectHsWrapBinders
  to pick off the lambda binders from the HsWapper

* dsWrapper now returns a (CoreExpr -> CoreExpr) function

* CoreUnfold.specUnfolding now takes a (CoreExpr -> CoreExpr)
  function it can use to specialise the unfolding.

On the whole the code is simpler than before.
compiler/coreSyn/CoreUnfold.hs
compiler/deSugar/DsArrows.hs
compiler/deSugar/DsBinds.hs
compiler/deSugar/DsExpr.hs
compiler/deSugar/Match.hs
compiler/specialise/Specialise.hs
compiler/typecheck/TcEvidence.hs
compiler/typecheck/TcInstDcls.hs
testsuite/tests/deSugar/should_compile/T12944.hs [new file with mode: 0644]
testsuite/tests/deSugar/should_compile/all.T
testsuite/tests/indexed-types/should_compile/T12444a.hs [new file with mode: 0644]