Define ZipList's Semigroup
Needs RevisionPublic

Authored by chris-martin on Mar 11 2017, 5:44 PM.

Details

Summary

ZipList actually also admits a monoid

instance Semigroup a => Monoid (ZipList a) where
    mempty = ZipList (repeat mempty)
    ZipList xs `mappend` ZipList ys = ZipList (zipWith (<>) xs ys)

but unfortunately I can't find a place to define the Monoid instance without introducing a circular import. Any suggestions?

chris-martin created this revision.Mar 11 2017, 5:44 PM
  • spacing consistency
RyanGlScott requested changes to this revision.Mar 11 2017, 6:52 PM
RyanGlScott added a subscriber: RyanGlScott.

Has this proposed change been discussed on the libraries mailing list? I'm quite reluctant to add new instances to base without some semblance of community consensus that they should go in.

This revision now requires changes to proceed.Mar 11 2017, 6:52 PM

Has this proposed change been discussed on the libraries mailing list? I'm quite reluctant to add new instances to base without some semblance of community consensus that they should go in.

I don't know. How do you search the mailing list?

A quick Google search reveals this: https://mail.haskell.org/pipermail/libraries/2015-July/026039.html

That discussion reveals a number of possible choices for Semigroup/Monoid implementations for ZipList, and the discussion ended without a clear winner.

If you want to pursue this further, I'd advise starting a new thread on the mailing list, and emphasize why your choice makes more sense than the other options.

austin resigned from this revision.Nov 9 2017, 11:35 AM