Successfully reported this slideshow.
Your SlideShare is downloading. ×

Category Theory in 10 Minutes

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Upcoming SlideShare
Running Free with the Monads
Running Free with the Monads
Loading in …3
×

Check these out next

1 of 22 Ad

Category Theory in 10 Minutes

Download to read offline

A 10 minute lightning talk that highlights the 3 most important aspects of Category Theory as it relates to Functional Programming.

A 10 minute lightning talk that highlights the 3 most important aspects of Category Theory as it relates to Functional Programming.

Advertisement
Advertisement

More Related Content

Slideshows for you (20)

Similar to Category Theory in 10 Minutes (20)

Advertisement

Recently uploaded (20)

Category Theory in 10 Minutes

  1. 1. Category Theory in 10 Minutes Jordan Parmer @ProfParmer
  2. 2. What’s Category Theory?
  3. 3. What’s Category Theory? Mathematical study of abstract algebras of functions Systems of functions among some objects
  4. 4. What’s a Category?
  5. 5. A B f
  6. 6. A B fObject Object Arrow/Morphism
  7. 7. A B fObject Arrow/Morphism Object Domain (f) Codomain (f)
  8. 8. A B C f g
  9. 9. A B C f g g ∘ f g ∘ f = g ( f ( a ) )
  10. 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. 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. 12. A B C h g g ∘ f D f h ∘ g
  13. 13. Category theory is just mathematicians playing Portal.
  14. 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. 15. https://medium.com/@sinisalouc/demistifying-the-monad-in-scala-part-2-a-category-theory-approach-2f0a6d370eff
  16. 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. 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. 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. 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. 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. 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. 22. Thanks! ANY QUESTIONS? You can find me at @ProfParmer

×