
Sorry, that seems to be exactly the instances which is originally proposed.
On 26 Jul 2015, at 09:20, Oleg Grenrus
wrote: On 26 Jul 2015, at 06:43, M Farkas-Dyck
wrote: On 26/07/2015 at 12:23:13 +0900, Fumiaki Kinoshita wrote:
There is another possible instance:
instance Semigroup a => Monoid (ZipList a) where mempty = ZipList [] mappend (ZipList xs0) (ZipList ys0) = ZipList (mappend xs0 ys0) where go (x:xs) (y:ys) = x <> y : go xs ys go xs [] = xs go [] ys = ys
This breaks the identity law.
instance Monoid a a => Monoid (ZipList a) where mempty = ZipList (repeat mempty) mappend (ZipList xs) (ZipList ys) = ZipList (zipWith (<>) xs ys)
No preference on actual proposal or the instance. I have no strong opinion whether Alternative and Monoid1 should be the same.
Cheers, Oleg Grenrus _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries