Skip to content

Instantly share code, notes, and snippets.

@parthopdas
Created July 27, 2020 01:32
Show Gist options
  • Save parthopdas/9a40cee8e860c3cce3789aab6a999e6c to your computer and use it in GitHub Desktop.
Save parthopdas/9a40cee8e860c3cce3789aab6a999e6c to your computer and use it in GitHub Desktop.
Common type classes

Functor

  • Interface: fmap
  • Base: -
  • Adds flavored to a type
  • Laws: 2

Applicative

  • Applicative (parallel) composition
  • Base: Functor
  • Interface: pure, apply
  • Laws: 4

Monad

  • Monadic (sequential) composition
  • Base: Applicative
  • Interface: {return, bind} OR {join}
  • Laws: 3

Monoid

  • Enables divide and conquer
  • Base: -
  • Interface: mempty, mappend
  • Laws: 3

Foldable

  • Reduce part in map-reduce
  • Base: -
  • Interface: {fold} OR {foldback}
  • Laws: 0

Traversable

  • list of async -> async of list
  • Base: Functor, Foldable
  • Interface: {traverse} OR {sequenceA}
  • Laws: 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment