Skip to content

Instantly share code, notes, and snippets.

@tonymorris
Created July 11, 2012 04:42
Show Gist options
  • Save tonymorris/3088073 to your computer and use it in GitHub Desktop.
Save tonymorris/3088073 to your computer and use it in GitHub Desktop.
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