Skip to content
Snippets Groups Projects
Forked from Glasgow Haskell Compiler / GHC
5905 commits behind the upstream repository.
  • Simon Peyton Jones's avatar
    dc27e15a
    Implement DeepSubsumption · dc27e15a
    Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
    This MR adds the language extension -XDeepSubsumption, implementing
    GHC proposal #511.  This change mitigates the impact of GHC proposal
    
    The changes are highly localised, by design.  See Note [Deep subsumption]
    in GHC.Tc.Utils.Unify.
    
    The main changes are:
    
    * Add -XDeepSubsumption, which is on by default in Haskell98 and Haskell2010,
      but off in Haskell2021.
    
      -XDeepSubsumption largely restores the behaviour before the "simple subsumption" change.
      -XDeepSubsumpition has a similar flavour as -XNoMonoLocalBinds:
      it makes type inference more complicated and less predictable, but it
      may be convenient in practice.
    
    * The main changes are in:
      * GHC.Tc.Utils.Unify.tcSubType, which does deep susumption and eta-expanansion
      * GHC.Tc.Utils.Unify.tcSkolemiseET, which does deep skolemisation
      * In GHC.Tc.Gen.App.tcApp we call tcSubTypeNC to match the result
        type. Without deep subsumption, unifyExpectedType would be sufficent.
    
      See Note [Deep subsumption] in GHC.Tc.Utils.Unify.
    
    * There are no changes to Quick Look at all.
    
    * The type of `withDict` becomes ambiguous; so add -XAllowAmbiguousTypes to
      GHC.Magic.Dict
    
    * I fixed a small but egregious bug in GHC.Core.FVs.varTypeTyCoFVs, where
      we'd forgotten to take the free vars of the multiplicity of an Id.
    
    * I also had to fix tcSplitNestedSigmaTys
    
      When I did the shallow-subsumption patch
        commit 2b792fac
        Date:   Sun Feb 2 18:23:11 2020 +0000
        Simple subsumption
    
      I changed tcSplitNestedSigmaTys to not look through function arrows
      any more.  But that was actually an un-forced change.  This function
      is used only in
    
      * Improving error messages in GHC.Tc.Gen.Head.addFunResCtxt
      * Validity checking for default methods: GHC.Tc.TyCl.checkValidClass
      * A couple of calls in the GHCi debugger: GHC.Runtime.Heap.Inspect
    
      All to do with validity checking and error messages. Acutally its
      fine to look under function arrows here, and quite useful a test
      DeepSubsumption05 (a test motivated by a build failure in the
      `lens` package) shows.
    
      The fix is easy.  I added Note [tcSplitNestedSigmaTys].
    dc27e15a
    History
    Implement DeepSubsumption
    Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
    This MR adds the language extension -XDeepSubsumption, implementing
    GHC proposal #511.  This change mitigates the impact of GHC proposal
    
    The changes are highly localised, by design.  See Note [Deep subsumption]
    in GHC.Tc.Utils.Unify.
    
    The main changes are:
    
    * Add -XDeepSubsumption, which is on by default in Haskell98 and Haskell2010,
      but off in Haskell2021.
    
      -XDeepSubsumption largely restores the behaviour before the "simple subsumption" change.
      -XDeepSubsumpition has a similar flavour as -XNoMonoLocalBinds:
      it makes type inference more complicated and less predictable, but it
      may be convenient in practice.
    
    * The main changes are in:
      * GHC.Tc.Utils.Unify.tcSubType, which does deep susumption and eta-expanansion
      * GHC.Tc.Utils.Unify.tcSkolemiseET, which does deep skolemisation
      * In GHC.Tc.Gen.App.tcApp we call tcSubTypeNC to match the result
        type. Without deep subsumption, unifyExpectedType would be sufficent.
    
      See Note [Deep subsumption] in GHC.Tc.Utils.Unify.
    
    * There are no changes to Quick Look at all.
    
    * The type of `withDict` becomes ambiguous; so add -XAllowAmbiguousTypes to
      GHC.Magic.Dict
    
    * I fixed a small but egregious bug in GHC.Core.FVs.varTypeTyCoFVs, where
      we'd forgotten to take the free vars of the multiplicity of an Id.
    
    * I also had to fix tcSplitNestedSigmaTys
    
      When I did the shallow-subsumption patch
        commit 2b792fac
        Date:   Sun Feb 2 18:23:11 2020 +0000
        Simple subsumption
    
      I changed tcSplitNestedSigmaTys to not look through function arrows
      any more.  But that was actually an un-forced change.  This function
      is used only in
    
      * Improving error messages in GHC.Tc.Gen.Head.addFunResCtxt
      * Validity checking for default methods: GHC.Tc.TyCl.checkValidClass
      * A couple of calls in the GHCi debugger: GHC.Runtime.Heap.Inspect
    
      All to do with validity checking and error messages. Acutally its
      fine to look under function arrows here, and quite useful a test
      DeepSubsumption05 (a test motivated by a build failure in the
      `lens` package) shows.
    
      The fix is easy.  I added Note [tcSplitNestedSigmaTys].
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
LanguageExts.stdout 559 B