... | ... | @@ -112,7 +112,7 @@ type family F x |
|
|
|
|
|
class C a b | b -> a
|
|
|
|
|
|
class C b b => D b
|
|
|
class C (F b) b => D b
|
|
|
|
|
|
f :: (C () b, D b) => Maybe b
|
|
|
f = g
|
... | ... | @@ -121,10 +121,10 @@ g :: (C a b) => Maybe b |
|
|
g = Nothing
|
|
|
```
|
|
|
|
|
|
In this situation, when typechecking `f`, GHC will see that we can obtain evidence for `C b b` from `D b` because of the superclass on `D`. Thus we get both `C () b` and `C b b`, and because of the functional dependency on `C`, GHC will require `() ~ b`. As that constraint wasn't provided in the type signature, the program is rejected. To make this program compile with 9.4 or later, add that as an explicit constraint:
|
|
|
In this situation, when typechecking `f`, GHC will see that we can obtain evidence for `C b b` from `D b` because of the superclass on `D`. Thus we get both `C () b` and `C (F b) b`, and because of the functional dependency on `C`, GHC will require `F () ~ b`. As that constraint wasn't provided in the type signature, the program is rejected. To make this program compile with 9.4 or later, add that as an explicit constraint:
|
|
|
|
|
|
```hs
|
|
|
f :: (C () b, D b, b ~ ()) => Maybe b
|
|
|
f :: (C () b, D b, F b ~ ()) => Maybe b
|
|
|
f = g
|
|
|
```
|
|
|
|
... | ... | |