Proposal: Functor and friends for the wrappers in Data.Monoid
Joachim Breitner
mail at joachim-breitner.de
Tue Feb 24 14:26:55 UTC 2015
Hi,
Am Dienstag, den 24.02.2015, 14:00 +0000 schrieb Jake McArthur:
> +1 do all instances of the proposal. It is so common for me to want to
> use some polymorphic function but it not be available to me because it
> has a constraint not satisfied by a newtype wrapper around the type I
> want to use it with, so I have to write a bunch of boilerplate. I
> think we should eliminate such boilerplate aggressively. I even think
> Applicative and Monad would be useful. Just because a wrapper doesn't
> add behavior doesn't mean we should intentionally make it incompatible
> with so much code.
your argument is valid: If I have a, say, "Num a", then I’d like to be
able to (+) also on values of type "Sum a". Hence the instance
Num a => Num (Sum a)
and others of that kind (Eq, Ord, Read, Show).
But your argument does not apply to the question at hand. The "Monad
Sum" instance is not of the „the instance of the wrapped thing lifted to
the newtype wrapper“ kind (as the wrapped thing has kind * and thus is
not a monad). Rather, it is the „there is only one only lawful Monad
instance for Identity, and Sum is isomorphic to Identity, so let’s use
it here“.
Greetings,
Joachim
--
Joachim “nomeata” Breitner
mail at joachim-breitner.de • http://www.joachim-breitner.de/
Jabber: nomeata at joachim-breitner.de • GPG-Key: 0xF0FBF51F
Debian Developer: nomeata at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20150224/e2b2691a/attachment.sig>
More information about the Libraries
mailing list