Skip to content

Instantly share code, notes, and snippets.

@ToJans
Last active December 13, 2015 22:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ToJans/849db810ca5f2e1f6f83 to your computer and use it in GitHub Desktop.
Save ToJans/849db810ca5f2e1f6f83 to your computer and use it in GitHub Desktop.
monads, applicatives, functors

Definitions

W<a>

A wrapper of type W that contains zero or more elements of type a.

c functionname(a,b)

A function named functionname that takes a value of type a, a value of type b and returns a value of type c.

F<a,b>

A function named F that takes a value of type a and returns a value of type b.

This is notation is equivalent to b F(a), but is used whenever we pass a function as a parameter.

Functor in W

W<b> fmap(W<a>,F<a,b>) 

Applicative in W

W<a> pure(a)
W<F<a,b>> pure(F<a,b>)
W<b> compose(W<a>,W<F<a,b>>)

Monad in W

W<a> return(a)
W<F<a,b>> return(F<a,b>)
W<b> bind(W<a>,F<a,W<b>>)

Note: Applicative.pure = Monad.return

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment