Skip to content
  • sheaf's avatar
    f596c91a
    Improve out-of-order inferred type variables · f596c91a
    sheaf authored and Marge Bot's avatar Marge Bot committed
      Don't instantiate type variables for :type in
      `GHC.Tc.Gen.App.tcInstFun`, to avoid inconsistently instantianting
      `r1` but not `r2` in the type
    
        forall {r1} (a :: TYPE r1) {r2} (b :: TYPE r2). ...
    
      This fixes #21088.
    
      This patch also changes the primop pretty-printer to ensure
      that we put all the inferred type variables first. For example,
      the type of reallyUnsafePtrEquality# is now
    
        forall {l :: Levity} {k :: Levity}
               (a :: TYPE (BoxedRep l))
               (b :: TYPE (BoxedRep k)).
          a -> b -> Int#
    
      This means we avoid running into issue #21088 entirely with
      the types of primops. Users can still write a type signature where
      the inferred type variables don't come first, however.
    
      This change to primops had a knock-on consequence, revealing that
      we were sometimes performing eta reduction on keepAlive#.
      This patch updates tryEtaReduce to avoid eta reducing functions
      with no binding, bringing it in line with tryEtaReducePrep,
      and thus fixing #21090.
    f596c91a
    Improve out-of-order inferred type variables
    sheaf authored and Marge Bot's avatar Marge Bot committed
      Don't instantiate type variables for :type in
      `GHC.Tc.Gen.App.tcInstFun`, to avoid inconsistently instantianting
      `r1` but not `r2` in the type
    
        forall {r1} (a :: TYPE r1) {r2} (b :: TYPE r2). ...
    
      This fixes #21088.
    
      This patch also changes the primop pretty-printer to ensure
      that we put all the inferred type variables first. For example,
      the type of reallyUnsafePtrEquality# is now
    
        forall {l :: Levity} {k :: Levity}
               (a :: TYPE (BoxedRep l))
               (b :: TYPE (BoxedRep k)).
          a -> b -> Int#
    
      This means we avoid running into issue #21088 entirely with
      the types of primops. Users can still write a type signature where
      the inferred type variables don't come first, however.
    
      This change to primops had a knock-on consequence, revealing that
      we were sometimes performing eta reduction on keepAlive#.
      This patch updates tryEtaReduce to avoid eta reducing functions
      with no binding, bringing it in line with tryEtaReducePrep,
      and thus fixing #21090.
Loading