stephenki / notes

https://github.com/stephenki/notes/issues
1 stars 0 forks source link

CT #1

Open stephenki opened 7 years ago

stephenki commented 7 years ago

https://bartoszmilewski.com/2014/10/28/category-theory-for-programmers-the-preface/

  1. The Essence of Composition
    f :: A -> B
    g :: B -> C
    h :: C -> D
    h . (g . f) == (h . g) . f == h . g . f
    f . id == f
    id . f == f

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.

stephenki commented 7 years ago
  1. Types and Functions bottom: https://wiki.haskell.org/Bottom http://chris-taylor.github.io/blog/2013/02/10/the-algebra-of-algebraic-data-types/
stephenki commented 7 years ago
class Monoid m where
    mempty :: m
    mappend :: m -> m -> m
stephenki commented 7 years ago
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)