ZipList
comes with a Functor
and an Applicative
instance (Control.Applicative) but why not Alternative
?
My guiding intuition for Alternative
comes from parsers which suggest that if one branch of your alternative fails somehow it should be eradicated thus leading to a Longest
-style Alternative
that probably isn't terrifically useful. This would be unbiased (unlike parsers) but fail on infinite lists.
Then again, all they must do, as you suggest, is form a Monoid
. Yours is left biased in a way that ZipList
doesn't usually embody, though—you could clearly form the reflected version of your Alternative
instance just as easily. As you point out, this is the convention with Maybe
as well, but I'm not sure there's any reason for ZipList
to follow that convention.
There's no sensible some
or many
I don't believe, although few Alternative
s actually have those—perhaps they'd have been better isolated into a subclass of Alternative
.
Frankly, I don't think your suggestion is a bad instance to have, but I don't have any confidence about it being "the" alternative instance implied by having a ZipList
. Perhaps it'd be best to see where else this kind of "extension" instance could apply (trees?) and write it as a library.