Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Semigroup/Monoid/Semigroupoid/Category/Endo
class Semigroupoid cat where
(<.>) ::
cat a b
-> cat b c
-> cat a c
class Semigroupoid cat => Category cat where
identity ::
cat a a
class Semigroup s where
(<>) ::
s
-> s
-> s
class Semigroup s => Monoid s where
zero ::
s
newtype Endo hom a = Endo (hom a a)
instance Semigroupoid hom => Semigroup (Endo hom a) where
Endo x <> Endo y =
Endo (x <.> y)
instance Category hom => Monoid (Endo hom a) where
zero =
Endo identity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment