serokell / universum

:milky_way: Prelude written in @Serokell
MIT License
176 stars 28 forks source link

Import '(<>)' from Semigroup, not Monoid #79

Closed chshersh closed 6 years ago

chshersh commented 6 years ago

For example, it's not very convenient to use Semigroup.<> when you need to append NonEmpty a.

neongreen commented 6 years ago

We already had (<>) from Semigroup in Universum and then we changed it because it was too much hassle ;)

chshersh commented 6 years ago

@neongreen Can you give an example of that? Probably I didn't face this issue...

neongreen commented 6 years ago

IIRC there were some types without Semigroup instances and so we had to import the Monoid (<>) fairly often. I don't remember which types those were.

int-index commented 6 years ago

We should've added Semigroup instances upstream, since it's in base

neongreen commented 6 years ago

Meanwhile I have found the relevant commit and it looks like there were only six modules where we had to hide (<>) from Universum. We are also using NonEmpty more often now so I guess I'm fine with exporting (<>) from Semigroup instead of Monoid provided that we also export mappend.

chshersh commented 6 years ago

We can just use mappend if we need Monoid. When Semigroup => Monoid lands in GHC 8.4.1 it will become much easier to migrate. Especially if we try by ourselves to use Semigroup instead of Monoid as much as possible.

gromakovsky commented 6 years ago

IIRC, most annoying example was some famous type from optparse-applicative.

chshersh commented 6 years ago

@gromakovsky This data type has instance Semigroup in last version of optparse-applicative.