How does the ambiguity check work

Richard Eisenberg rae at richarde.dev
Mon Sep 30 08:44:21 UTC 2019


Hi Jan,

The ambiguity check has a simple description. To test if a type `ty` is ambiguous, do this:

```
x :: ty
x = x
```

Iff that type-checks, the type is unambiguous. That's it!

The check does not manufacture a binding `x`, but the implementation runs through the type-checking process for a binding just like the one I've written here.

In your case, I have two hypotheses:
1. Presumably, you have a solver plugin at work. That may explain the difference in behavior between the two cases.
2. There may be kind variables at work, and these may end up ambiguous. It's definitely worth trying with -fprint-explicit-kinds.

I hope this helps!
Richard


More information about the ghc-devs mailing list