I'd like to write an Alternative instance for the Identity newtype. The skeleton isn't hard:
instance Alternative Identity where
empty = _
(<|>) = _
However, the implementation is impossible for all types. It would be easy if I have a Monoid instance for a though:
instance Alternative Identity where
empty = Identity mempty
(Identity a) <|> (Identity a') = Identity (a <> a')
Is there a way to tell the compiler that I want to define the Alternative instance only for when the type inside has a Monoid instance? Since the a isn't mentioned anywhere, I can't just use a constraint Monoid a =>.