6

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
Clinton
  • 22,361
  • 15
  • 67
  • 163

1 Answers1

11

Yep. That would be called Dual.

Machavity
  • 30,841
  • 27
  • 92
  • 100
luqui
  • 59,485
  • 12
  • 145
  • 204