Skip to content

Instantly share code, notes, and snippets.

@enricopolanski
Created June 14, 2019 16:18
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 enricopolanski/1e20b9dcdca85a3fd03b0e6d327e3dcc to your computer and use it in GitHub Desktop.
Save enricopolanski/1e20b9dcdca85a3fd03b0e6d327e3dcc to your computer and use it in GitHub Desktop.
Functional JS/TS
// A Functor is "something" we can map: to be specific it is a mapping between categories that preserves the categorical structure, i.e. that preserve identity morphisms and composition.
// Since categories are constituted of two things (objects and morphisms) a functor is constituted of two things as well:
// - a mapping between objects that associates to each object x in C an object in D
// - a mapping between morphisms that associates to each morphism in C a morphism in D
Array, Tree, Stream, Promise are all functors, we can map all of them.
// A Monad is a functor that we can flatMap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment