Liftin every day

Post on 23-Jun-2015

438 views 2 download

Tags:

description

Every day use of applicative functors in javascript

Transcript of Liftin every day

Liftin’ Every Day

Applicative Functors?

pure :: a -> f a

ap :: f (a -> b) -> f a -> f b

Closed Under Composition

Closed Under Composition

Closed Under Composition

Closed Under Composition

liftA :: (a -> b) -> f a -> f bliftA2 :: (a -> b -> c) -> f a -> f

b -> f c

liftA :: (a -> b) -> f a -> f bliftA2 :: (a -> b -> c) -> f a -> f

b -> f c

Just fmap

liftA :: (a -> b) -> f a -> f bliftA2 :: (a -> b -> c) -> f a -> f

b -> f c

Just fmap

We can get arityautomatically

ap(pure(f), x, y) == liftA(f, x, y)

Ultimate Combinator

f(g(x), h(x),..n(x))

f(g(x), h(x))

f(g(x), h(x))

List Comprehensions

A Quick Word about Comma Overloading

ZipLists

ap([f, g], [x,y])[f(x), f(y), g(x), g(y)]

-or-

ap([f, g], [x,y])[f(x), g(y)]

ap([f, g], [x,y])[f(x), f(y), g(x), g(y)]

-or-

ap([f, g], [x,y])[f(x), g(y)]

ZipList

Eventual Results

Combinators

Comprehensions

Semaphores

Parallel Computations

Composition

Lots more I didn’t get to...

•http://looprecur.com

•@drboolean

•drboolean.tumblr.com

•https://github.com/loop-recur/typeclasses

THANKS!