# ☯ old name of yin-yang symbol. # category theory algebraic monoids are semigroups w/ identity, that is a set w/ associative binary operator `*` and - associativity: `(a * b) * c = a * (b * c)` - identity: existence of `e` so that `e * a = a * e = a`. category theory knows abstract monoids and monads as further abstraction. a monad on category `C` is an endofunctor `T` together with two natural transformations `mu` and `eta` and two conditions. in algebraic terms these conditions resemble associativity and identity with - `mu` resembles binary operation - `eta` resembles identity element. # functional programming: haskell from http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html about "extending functions". - `bind`: compose extended functions, written as `*` - `unit`: identity function regarding `bind` - `unit`: `f * unit = unit * f = f` - `lift`: extend "normal" function, `lift f = unit . f` - `lift` is associative: `lift f * lift g = lift(f . g)` examples: - debuggable function w/ extra string as output - complex square and cubic root, differently length output array - random numbers in haskell abstract: - given function `f : a -> m b` which needs to be applied to `m a` instead of `a` - define `bind : (a -> m b) -> (m a -> m b)`, hence follows `*` - define `unit : a -> m a`, hence follows `lift` - `unit` is neutral regarding `*` - `lift` is associative regarding `*` a `monad` is a triple `(m, unit, bind)` following above laws. ## usual definition - `bind` is usually written as operator `>>=`, so `bind f x` equals `x >>= f` - `unit` is usually called `return` - handled by overloading type classes in haskell debuggable example is writer monad, multivalued is list monad, randomised is state monad.