Your SlideShare is downloading.
×

- 1. Category Theory in 10 Minutes Jordan Parmer @ProfParmer
- 2. What’s Category Theory?
- 3. What’s Category Theory? Mathematical study of abstract algebras of functions Systems of functions among some objects
- 4. What’s a Category?
- 5. A B f
- 6. A B fObject Object Arrow/Morphism
- 7. A B fObject Arrow/Morphism Object Domain (f) Codomain (f)
- 8. A B C f g
- 9. A B C f g g ∘ f g ∘ f = g ( f ( a ) )
- 10. A B C f g g ∘ f Object domain(f) Arrow Composite Object codomain(f) domain(g) Arrow Object codomain(g)( g ◦ f )( a ) = g ( f ( a ) ) a ∈ A
- 11. A B C f g g ∘ f ● Unit (identity) law: 1A : A → A, f ∘ 1A = f = 1B ∘ f ● Associativity law: h ∘ (g ∘ f) = (h ∘ g) ∘ f
- 12. A B C h g g ∘ f D f h ∘ g
- 13. Category theory is just mathematicians playing Portal.
- 14. Oh the names we’ll use... Category theory is comprised of many small, simple laws. Adding a certain combination of laws together forms various algebraic structures each with their own name.
- 15. https://medium.com/@sinisalouc/demistifying-the-monad-in-scala-part-2-a-category-theory-approach-2f0a6d370eff
- 16. Functional Concepts Functor Transforms from one category to another. A => B B => C Endofunctor Transforms objects between same category. (e.g. Functor in the category of types) Int => Int String => Int String => TaskResult
- 17. Functional Concepts Functor Transforms from one category to another. A => B B => C Endofunctor Transforms objects between same category. (e.g. Functor in the category of types) Int => Int String => Int String => TaskResult Functors in most programming languages are all endofunctors because most programming languages are in the category of Types.
- 18. Functional Concepts Functor Transforms from one category to another. A => B B => C Endofunctor Transforms objects between same category. (e.g. Functor in the category of types) Int => Int String => Int String => TaskResult Often called ‘map’ or ‘fmap’ function Ex: “pickle”.map(c => c + “z”) Yields: (“pz”, “iz”, “cz”, “kz”, “lz”, “ez”)
- 19. Functional Concepts Semigroup ◦ Append Append 1 + 2 “Hello” + “World” [1, 2, 3] + [4, 5, 6] Monoid ◦ Identity ◦ Append Identity 0 + 1 == 1 + 0 == 1 “” + “A” == “A” + “” == “A” [ ] + [1] == [1] + [ ] == [1] *Append -> binary associative operator
- 20. Functional Concepts Monad ◦ Identity as Apply ◦ Append as Flatten Monoid in the category of endofunctors. For all practical purposes, it is a monoid that can be flattened if the inner type is itself a monoid. Maybe(Maybe(T)) to Maybe(T) List(List(T)) to List(T) List(Maybe(T)) to List(T)
- 21. Chaining Monads Pictures by Aditya Bhargava https://tinyurl.com/cmvrfpb “Bind” operation plucks value from monadic context and applies it to next function returning it back in context.
- 22. Thanks! ANY QUESTIONS? You can find me at @ProfParmer