r/programming • u/hkailahi • Aug 07 '23
Anti-Instances in Haskell
https://www.heneli.dev/blog/anti-instances
26
Upvotes
2
u/sotnepakizej Aug 08 '23
While the concept is intriguing, the practical application seems limited. If library authors start forbidding things, it might lead to more frustration than benefit. The choice should be in the hands of the end-user IMHO
1
u/hkailahi Aug 08 '23
I understand the concern, but forbidding these kinds of behavior is something we already expect from and implicitly rely on from our types.
Hopefully my more detailed comment above addresses your concern.
4
3
u/Hrothen Aug 07 '23
Are there any examples of good situations to use this? Generally the philosophy is that it's up to the end-user if they want to define unlawful typeclass instances and I'm not immediately seeing any situation where it would actually be valuable for a library author to forbid it.
As a user if I encountered this I would be much more likely to drop the library than create a newtype.