Skip to content

Instantly share code, notes, and snippets.

@Jeffrey04
Last active May 25, 2017 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jeffrey04/9c21877f54f6b9540ddc3412e5d1137e to your computer and use it in GitHub Desktop.
Save Jeffrey04/9c21877f54f6b9540ddc3412e5d1137e to your computer and use it in GitHub Desktop.
Category Theory Note dump

Terms

morphism = function = arrow category: objects and arrows source = origin of arrow target = destination of arrow

haskell

f :: A -> B

function f requires an input of type A, and returns B

id :: a -> a
id x = x

names of concrete type always start with a capital letter names of type variables always start with a lowercase letter a stands for all types

func :: a -> a
func x = x

function definition:

  • name of the function followed by formal parameters
  • body of the function follows the equal sign
  • no parentheses around argument list
  • no commas between arguments

composition

given a morphism from A to B, and another from B to C, then there must be an morphism from A to C

properties

  1. composition is associative
f :: A -> B
g :: B -> C
h :: C -> D
h . (g . f) = (h . g) . f = h . g . f
  1. unit of composition, which is a morphism loops from object to itself (unit arrow, or identity arrow), hence if composing any arrow with the involved two objects' unit arrow, it will return the same arrow. For example, for a morphism f between A and B,
f . id_A = f
id_B . f = f

the identity arrow is similar to the following javascript arrow function

a => a
  1. target object of an arrow, must be the source object of next arrow

sets and types

  • Set is a special category
  • can get intuitions from peeking inside its objects, i.e.
    • an empty set has no element
    • there are special one-element set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment