Fix the treatment of 'closed' definitions

Authored by simonpj on Jun 16 2017, 4:16 PM.


Fix the treatment of 'closed' definitions

The IdBindingInfo field of ATcId serves two purposes

  • to control generalisation when we have -XMonoLocalBinds
  • to check for floatability when dealing with (static e)

These are related, but not the same, and they'd becomme confused.
Trac Trac #13804 showed this up via an example like this:

f periph = let sr :: forall a. [a] -> [a]
               sr = if periph then reverse else id

               sr2 = sr
               -- The question: is sr2 generalised?
               -- It should be, because sr has a type sig
               -- even though it has periph free
           (sr2 [True], sr2 "c")

Here sr2 should be generalised, despite the free var 'periph'
in 'sr' because 'sr' has a closed type signature.

I documented all this very carefully this time, in TcRnTypes:

Note [Meaning of IdBindingInfo]
Note [Bindings with closed types: ClosedTypeId]