Proposal: Functor and friends for the wrappers in Data.Monoid
Henning Thielemann
schlepptop at henning-thielemann.de
Sun Feb 22 13:43:39 UTC 2015
Am 22.02.2015 um 09:25 schrieb Edward Kmett:
> I generally feel having these only-one-way-to-do-it instances just
> defined is better than forcing orphans upon those who _do_ want them.
>
> Inevitably those users seem to wind up with separate orphans that tend
> to collide, or just give up and define their own type. Both of those
> outcomes are rather suboptimal.
I am generally opposed to adding instances just because there is one and
only one way to write them. For me instances must also have some
reasonable use. Every defined instance reduces the chance to find a
silly error early. The question is: Is using the instance Monad Sum more
likely to be useful or more likely to be an accident? I guess it is the
second one. Then I would propose to use the known technique to write an
instance that cannot be defined fully:
https://ghc.haskell.org/trac/ghc/ticket/9334#comment:9
This way, programmers can achieve more confidence in their code and
orphan instances are ruled out. I also think that it is easier to switch
from an unimplementable instance to an implemented instance if someone
finds a use, than to alter or remove an intentionally implemented instance.
More information about the Libraries
mailing list