Typing regression on HEAD (for a long time already), e.g. vector-algorithms doesn't type-check (horde-ad, too)
## Summary
For many commits now HEAD can't type-check vector-algorithms nor horde-ad in a way that suggests a GHC bug, not a bugfix that is not backward compatible.
## Steps to reproduce
With HEAD from 8b080e048d51defa19fe9a484ec922b880a22a8b do
`cabal install --lib vector-algorithms --allow-newer --disable-optimization -w /home/mikolaj/r/ghc.Andreas/ghc/_build/stage1/bin/ghc`
You should get the following suspect error message
```
src/Data/Vector/Algorithms/Tim.hs:128:17: error: [GHC-39999]
• Could not deduce ‘MVector v e’ arising from a use of ‘new’
from the context: (PrimMonad m, MVector v e)
bound by the type signature for:
sortBy :: forall (m :: * -> *) (v :: * -> * -> *) e.
(PrimMonad m, MVector v e) =>
Comparison e -> v (PrimState m) e -> m ()
at src/Data/Vector/Algorithms/Tim.hs:(124,1)-(125,51)
Possible fix:
add (MVector v e) to the context of
the type signature for:
sortBy :: forall (m :: * -> *) (v :: * -> * -> *) e.
(PrimMonad m, MVector v e) =>
Comparison e -> v (PrimState m) e -> m ()
• In the first argument of ‘(>>=)’, namely ‘new 256’
In the expression: new 256 >>= iter [] 0
In an equation for ‘sortBy’:
sortBy cmp vec
| mr == len = iter [0] 0 (error "no merge buffer needed!")
| otherwise = new 256 >>= iter [] 0
where
len = length vec
mr = minrun len
iter s i tmpBuf
| i >= len = performRemainingMerges s tmpBuf
| otherwise
= do (order, runLen) <- nextRun cmp vec i len
when ... $ ...
...
runLengthInvariantBroken a b c i
= (b - a <= i - b) || (c - b <= i - c)
performMerges [b, a] i tmpBuf
| i - b >= b - a
= merge cmp vec a b i tmpBuf >>= performMerges [a] i
performMerges (c : b : a : ss) i tmpBuf
| runLengthInvariantBroken a b c i
= if i - c <= b - a then
merge cmp vec b c i tmpBuf >>= performMerges (b : ...) i
else
do tmpBuf' <- merge ...
...
performMerges s _ tmpBuf = return (s, tmpBuf)
...
|
128 | | otherwise = new 256 >>= iter [] 0
| ^^^
```
HEAD from today fails even more horribly with horde-ad, so probably it would break vector-algorithms as well, but I can't easily test this any more. HEAD at 79df1e0ee23e7d349f99bb966fd5e15205231854 fails to compile vector-algorithms in the same way. The same with fcf6331e60a401244c8967d4c16d630af0c4b814. The newest commit I tried that compiles vector-algorithms (and horde-ad) fine is f8919262dc3034851fbefab86fe45dd7963ffed5.
## Expected behavior
Type-checks.
## Environment
* GHC version used: HEAD
Optional:
* Operating System: Ubuntu
* System Architecture: AMD64
issue