Skip to content
  • Simon Peyton Jones's avatar
    Fix the treatment of 'closed' definitions · dc8e6861
    Simon Peyton Jones authored
    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 #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
                 in
                 (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]
    dc8e6861