Fix: use Unsatisfiable for banned instances (unrestricted Monoid / Semigroup for linear containers)#494
Conversation
|
You have multiple build failures. |
|
@treeowl Thank you for pointing it out! Then I will introduce compat module before/after GHC 9.8 and put your code (with naming tweaking) for older versions. |
|
Ah, indeed there is already one - `Prelude.Linear.Unsatisfiable. In this time, I just use them. |
aspiwack
left a comment
There was a problem hiding this comment.
I'm not too sure about this. The message isn't suppose to ever reach the user, if the message surfaces it would be a bug in the library. Have you experienced this error message? (if so, please report a bug 🥺)
I don't actually remember why we have these instances to begin with. My best guess is that at some point, we'd decided that the Prelude's Semigroup class was a superclass to the linear Semigroup class. And so we'd absolutely needed a Prelude.Semigroup instance for Hashmaps if they were to have a linear Semigroup instance.
But maybe we don't need these instances. How about simply deleting them instead?
|
An
|
|
Fair enough. Are the messages I suggest clear enough? I haven't spend much time wordsmithing. |
Unrestricted Semigroup/Monoid instances for containers whose values are always linear.
8a0cf1d to
732f41b
Compare
aspiwack
left a comment
There was a problem hiding this comment.
I cleaned up the history. Let's merge.
Currently,
Prelude.Semigroupinstance for (linear) HashMap / Set results in a runtime error.This PR explicitly bans these instances by using
Unsatisfiabletype constraint family.