Closed treeowl closed 2 years ago
This change causes compilation failures in the benchmark suite. I tried to patch that up using an incoherent instance (to let type information flow from the result type to the second argument type):
instance {-# INCOHERENT #-} (SuperComposition x y d q, cd ~ (c -> d)) =>
SuperComposition x y cd (c -> q) where
(f ... g) c = (...) @x @y @d @q f (g c)
{-# INLINE (...) #-}
For some reason, that leads to a reduction stack overflow in the benchmark, which I find extremely mysterious. It looks to me like at least one type argument gets smaller in each recursive call, and none get larger. What am I missing???
Oh, of course, that particular instance is just wrong, because the arrows could come from the first argument. Whoops! I think it's okay to break this a little, in exchange for more stable behavior.
Where should I put a migration guide?
Use overlapping instances instead of incoherent ones. Fixes #265.
Make the first argument of
...
a function unconditionally, before instance selection. This can theoretically improve inference slightly, though it probably doesn't have much impact in practice.Description
Related issues(s)
✓ Checklist for your Pull Request
Ideally a PR has all of the checkmarks set.
If something in this list is irrelevant to your PR, you should still set this checkmark indicating that you are sure it is dealt with (be that by irrelevance).
Related changes (conditional)
Tests
Documentation
I checked whether I should update the docs and did so if necessary:
Record your changes
Stylistic guide (mandatory)
[ ] My commit history is clean (only contains changes relating to my issue/pull request and no reverted-my-earlier-commit changes) and commit messages start with identifiers of related issues in square brackets.
Example:
[#42] Short commit description
If necessary both of these can be achieved even after the commits have been made/pushed using rebase and squash.