summaryrefslogtreecommitdiff
path: root/libraries/ghc-prim
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2022-03-01 17:36:48 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-03-02 14:09:51 -0500
commitf596c91aaede75f7293ac2214ad48018a6b7a753 (patch)
tree92c51240f4d7237d03868d27ddada78a0819cc14 /libraries/ghc-prim
parent81b7c4361c0e3da403e0fcf42cc7faae2ca3db9a (diff)
downloadhaskell-f596c91aaede75f7293ac2214ad48018a6b7a753.tar.gz
Improve out-of-order inferred type variables
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.
Diffstat (limited to 'libraries/ghc-prim')
-rw-r--r--libraries/ghc-prim/changelog.md24
1 files changed, 14 insertions, 10 deletions
diff --git a/libraries/ghc-prim/changelog.md b/libraries/ghc-prim/changelog.md
index 372018290b..0485c633af 100644
--- a/libraries/ghc-prim/changelog.md
+++ b/libraries/ghc-prim/changelog.md
@@ -96,7 +96,7 @@
```
newMutVar#
- :: forall s {l :: Levity} (a :: TYPE (BoxedRep l)).
+ :: forall {l :: Levity} s (a :: TYPE (BoxedRep l)).
a -> State# s -> (# State# s, MVar# s a #)
```
@@ -104,7 +104,7 @@
```
writeSmallArray#
- :: forall s {l :: Levity} (a :: TYPE ('BoxedRep l)).
+ :: forall {l :: Levity} s (a :: TYPE ('BoxedRep l)).
SmallMutableArray# s a -> Int# -> a -> State# s -> State# s
```
@@ -117,8 +117,9 @@
```
mkWeakNoFinalizer#
- :: forall {l :: Levity} (a :: TYPE ('BoxedRep l))
- {k :: Levity} (b :: TYPE ('BoxedRep k)).
+ :: forall {l :: Levity} {k :: Levity}
+ (a :: TYPE ('BoxedRep l))
+ (b :: TYPE ('BoxedRep k)).
a -> b -> State# RealWorld -> (# State# RealWorld, Weak# b #)
```
@@ -133,8 +134,9 @@
```
catch#
- :: forall {r :: RuntimeRep} (a :: TYPE r)
- {l :: Levity} (b :: TYPE ('BoxedRep l)).
+ :: forall {r :: RuntimeRep} {l :: Levity}
+ (a :: TYPE r)
+ (b :: TYPE ('BoxedRep l)).
( State# RealWorld -> (# State# RealWorld, a #) )
-> ( b -> State# RealWorld -> (# State# RealWorld, a #) )
-> State# RealWorld -> (# State# RealWorld, a #)
@@ -152,8 +154,9 @@
(with an inferred `RuntimeRep` argument) and levity-polymorphic, with type:
```
- raise# :: forall {l :: Levity} (a :: TYPE (BoxedRep l))
- {r :: RuntimeRep} (b :: TYPE r).
+ raise# :: forall {l :: Levity} {r :: RuntimeRep}
+ (a :: TYPE (BoxedRep l))
+ (b :: TYPE r).
a -> b
```
@@ -169,8 +172,9 @@
```
reallyUnsafePtrEquality#
- :: forall {l :: Levity} (a :: TYPE (BoxedRep l))
- {k :: Levity} (b :: TYPE (BoxedRep k))
+ :: forall {l :: Levity} {k :: Levity}
+ (a :: TYPE (BoxedRep l))
+ (b :: TYPE (BoxedRep k))
. a -> b -> Int#
```