Open stephenki opened 7 years ago
class Monoid m where
mempty :: m
mappend :: m -> m -> m
Numbers | Types |
---|---|
0 | Void |
1 | () |
a + b | Either a b = Left a | Right b |
a * b | (a, b) or Pair a b = Pair a b |
2 = 1 + 1 | data Bool = True | False |
1 + a | data Maybe = Nothing | Just a |
Logic | Types |
---|---|
false | Void |
true | () |
a || b | Either a b = Left a | Right b |
a && b | (a, b) |
https://bartoszmilewski.com/2014/10/28/category-theory-for-programmers-the-preface/
A category consists of objects and arrows (morphisms). Arrows can be composed, and the composition is associative. Every object has an identity arrow that serves as a unit under composition.