Haskell newtype that flips semigroup operation?

209 Views Asked by At

Is there any newtype in base that would basically achieve the following?

newtype SemigroupFlip a = SemigroupFlip a

instance Semigroup a => Semigroup (SemigroupFlip a) where
  (SemigroupFlip a) <> (SemigroupFlip b) = SemigroupFlip (b <> a)

instance Monoid a => Monoid (SemigroupFlip a) where
  mempty = SemigroupFlip mempty
1

There are 1 best solutions below

0
On BEST ANSWER

Yep. That would be called Dual.