2 ms·
> Haskell developers incorrectly assume that you can only have one semi group (or equality, monoid, etc) instances for your data type They don't assume that. T
by marcosdumay 2y ago
> Haskell developers incorrectly assume that you can only have one semi group (or equality, monoid, etc) instances for your data type
They don't assume that. The devs bent the compiler backwards several times trying to support more than one instance, but they still couldn't design an implementation that is actually good to use.
If you know of any language where this works well, it would be nice to know. AFAIK, representing that kind of thing is an open problem, nobody has an answer.
- quchen 2y agoI think Idris addresses this fairly well, if there's more than one instance (and the code is ambiguous) you have to annotate which one.
- ndriscoll 2y agoScala does it well. Implicits make it easy to pass along the instance you mean. You can put a default on the companion object if you want, but you can override where needed. Implicits on the companion object have lower priority than those in current scope.
- epolanski 2y agoScala/Typescript