Regression in 9.14 instance resolution for local `let`-function
Over GHC 9.12.2 (and every major version before that), GHC 9.14 alpha1 misses to infer an instance.
```haskell
import Data.Bifunctor (first)
works x y = first (const x) <$> y
main = do
let fails x y = first (const x) <$> y
return ()
```
GHC 9.12 can still infer types for both `works` and `fails`, but GHC 9.14 fails for `fails`:
```
InferBifunctor.hs:6:19: error: [GHC-39999]
• Could not deduce ‘Data.Bifunctor.Bifunctor p0’
arising from a use of ‘first’
from the context: Functor f
bound by the inferred type of
fails :: Functor f => b -> f (p0 a c) -> f (p0 b c)
at InferBifunctor.hs:6:7-39
The type variable ‘p0’ is ambiguous
Relevant bindings include
y :: f (p0 a c) (bound at InferBifunctor.hs:6:15)
fails :: b -> f (p0 a c) -> f (p0 b c)
(bound at InferBifunctor.hs:6:7)
Potentially matching instances:
instance [safe] Data.Bifunctor.Bifunctor Either
-- Defined in ‘Data.Bifunctor’
instance [safe] Data.Bifunctor.Bifunctor (,)
-- Defined in ‘Data.Bifunctor’
...plus five others
...plus two instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
• In the first argument of ‘(<$>)’, namely ‘first (const x)’
In the expression: first (const x) <$> y
In an equation for ‘fails’: fails x y = first (const x) <$> y
|
6 | let fails x y = first (const x) <$> y
| ^^^^^
InferBifunctor.hs:6:19: error: [GHC-05617]
• Could not deduce ‘forall a. Functor (p0 a)’
arising from a superclass required to satisfy ‘Data.Bifunctor.Bifunctor
p0’,
arising from a use of ‘first’
from the context: Functor f
bound by the inferred type of
fails :: Functor f => b -> f (p0 a c) -> f (p0 b c)
at InferBifunctor.hs:6:7-39
• In the first argument of ‘(<$>)’, namely ‘first (const x)’
In the expression: first (const x) <$> y
In an equation for ‘fails’: fails x y = first (const x) <$> y
|
6 | let fails x y = first (const x) <$> y
```
## Environment
* GHC version used: 9.14 alpha1
Optional:
* Operating System: macOS
* System Architecture: arm64
issue