Skip to content

Instantly share code, notes, and snippets.

@dewey92
Last active June 27, 2017 05:36
Show Gist options
  • Select an option

  • Save dewey92/9d813de92f5b95bfc46d0eddda13cb0a to your computer and use it in GitHub Desktop.

Select an option

Save dewey92/9d813de92f5b95bfc46d0eddda13cb0a to your computer and use it in GitHub Desktop.
// pure :: Applicative f => a → f a
const pure = a => Functor.of(a)
// ap :: Applicative f => f (a → b) → f a → f b
const ap = (functor1, functor2) => functor1.ap(functor2)
// liftA :: Applicative f => (a → b) → f a → f b
const liftA = (fn, functor1) => functor1.map(fn)
// liftA2 :: Applicative f => (a → b → c) → f a → f b → f c
const liftA2 = (fn, functor1, functor2) => ap(functor1.map(fn), functor2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment