The Ap newtype wrapper provides a way of using an Applicative instance as a Monoid instance.
I think a similar thing can be done for Semialign and Align.
newtype Al f a = Al { getAl :: f a }
instance (Semialign f, Semigroup a) => Semigroup (Al f a) where
Al a <> Al b = Al (salign a b)
instance (Align f, Semigroup a) => Monoid (Al f a) where
mempty = Al nil
The Monoid laws should follow from salign being associative and nil being an identity of salign.
I haven't looked at other type classes, but perhaps this admits instances for them too.
The
Ap
newtype wrapper provides a way of using anApplicative
instance as aMonoid
instance. I think a similar thing can be done forSemialign
andAlign
.The
Monoid
laws should follow fromsalign
being associative andnil
being an identity ofsalign
.I haven't looked at other type classes, but perhaps this admits instances for them too.