Is it a good idea to create a type for monoid morphisms? it would "only" serve as a marker that something is assumed to be a monoid morphism. In some cases we know externally that something is a monoid morphism; on the other hand, library users could then "fix" errors by simply building onesuch.
Sample code:
final
class MonoidMorphism[MCat <: MonoidalCategory, M <: Monoid.In[MCat], N <: Monoid.In[MCat]](val f: MCat#On#C[M#M, N#M])
final
class MonoidsCategory[MCat <: MonoidalCategory](val mcat: MCat) extends Category {
type Objects =
Monoid.In[MCat]
type C[A <: Objects, B <: Objects] =
MonoidMorphism[MCat, A, B]
def identity[X <: Objects]: C[X,X] =
new MonoidMorphism( Category.is(MonoidalCategory.is(mcat).on).identity )
def composition[X <: Objects, Y <: Objects, Z <: Objects]: C[X,Y] × C[Y,Z] -> C[X,Z] =
λ((_:C[X,Y]).f) × λ((_:C[Y,Z]).f) >-> Category.is(MonoidalCategory.is(mcat).on).composition >-> λ(new MonoidMorphism(_))
}
Is it a good idea to create a type for monoid morphisms? it would "only" serve as a marker that something is assumed to be a monoid morphism. In some cases we know externally that something is a monoid morphism; on the other hand, library users could then "fix" errors by simply building onesuch.
Sample code: