Skip to content

Applicative instances of IsBlock, IsInline etc.#163

Merged
jgm merged 2 commits intojgm:masterfrom
AshleyYakeley:applicative
Mar 18, 2025
Merged

Applicative instances of IsBlock, IsInline etc.#163
jgm merged 2 commits intojgm:masterfrom
AshleyYakeley:applicative

Conversation

@AshleyYakeley
Copy link
Copy Markdown
Contributor

No description provided.

@AshleyYakeley AshleyYakeley mentioned this pull request Mar 17, 2025
@jgm
Copy link
Copy Markdown
Owner

jgm commented Mar 17, 2025

Just trying to think about the implications of UndecideableInstances and the overlap.

I've never really been clear about the potential dangers of the former, but I was under the impression that the common wisdom was to avoid it. Maybe you can tell me more?

As for the overlapping, I take it that this would still allow you to define your own newtype wrapper that is an instance of Applicative but that diverges from this default in the way it renders certain elements?

@AshleyYakeley
Copy link
Copy Markdown
Contributor Author

  • Ordinarily GHC requires that the superclass of an instance is "smaller" than the instance head. This is to prevent non-termination during compilation (although GHC will actually stop anyway after 200 reductions). UndecideableInstances switches this restriction off. Note that you are already using UndecideableInstances in some files prior to this PR.
  • For overlapping, given that the more general instances (f a) are marked OVERLAPPABLE, you can have more specific instances e.g. (SourceMap a) which take priority. When GHC is trying to solve e.g. the constraint (IsInline (SourceMap a)), while both the instances match, GHC will pick the one that isn't marked OVERLAPPABLE.

@jgm
Copy link
Copy Markdown
Owner

jgm commented Mar 18, 2025

Note that you are already using UndecideableInstances in some files prior to this PR.

I don't see that in any of the code in this repository. It could be that I've used it in some other project.

Anyway, I'm persuaded that this won't cause problems.

@jgm jgm merged commit 2935542 into jgm:master Mar 18, 2025
9 checks passed
@AshleyYakeley
Copy link
Copy Markdown
Contributor Author

I spelled it wrong, it's UndecidableInstances.

@jgm
Copy link
Copy Markdown
Owner

jgm commented Mar 18, 2025

Ah yes, you're right, we already use that!

@AshleyYakeley
Copy link
Copy Markdown
Contributor Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants