Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Power of Small Abstractions

The Power of Small Abstractions

Talk given at:
XConf (Hamburg, July 7th 2015)
XConf (Manchester, July 9th 2015)
Eurucamp (Berlin, August 2nd 2015)
JSConf EU (Berlin, September 25-27th 2015)

Josep M. Bach (Txus)

July 07, 2015
Tweet

More Decks by Josep M. Bach (Txus)

Other Decks in Programming

Transcript

  1. Abstraction. By Smok Bazyli (Own work) [CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0)],

    via Wikimedia Commons Image taken by Robert Southworth, 2004-9-4.
  2. “I suspect, nonetheless, that he wasn’t much capable of thinking.

    To think is to forget differences, to generalise, to abstract.” Jorge Luis Borges
  3. + =

  4. 0

  5. + =

  6. + =

  7. (map f collection) Applies f to each element of in

    collection, if any. Returns a collection with the transformed elements, or an empty one if the original was empty.
  8. (map f option) Applies f to the only element in

    option, if it’s there. Returns an option containing the transformed element or None.
  9. (map f future) Applies f to the element that the

    future may eventually yield, if it ever does. Returns a future that’ll yield either the transformed element or an error.
  10. (map f ) Applies f to whatever is inside in

    the way sees fit. Returns the result in the same kind of .
  11. (first []) (value (none)) Don’t reach into the box. (await

    (future (sleep)) nil? error? nil? error? blocks thread!
  12. (fapply …) Applies whatever function is inside taking each _

    as arguments, assuming they are all the same kind of box, in the way the boxes see fit. f f
  13. (fapply Applies whatever function is inside _ as arguments, assuming

    they are all the same kind of box, in the way the boxes see fit. f f Applicative functors.
  14. (flatmap f collection) Applies f to every element in collection,

    and then concatenates the results (presumably a nested collection) into a single flattened collection.
  15. (flatmap f optional) Applies f to the element in optional

    if it’s there, then flattens the result (presumably a nested optional) a single flattened optional.
  16. (flatmap f future) Applies f to the element eventually yielded

    by future, then flattens the result (presumably a nested future) a single flattened future.
  17. Applies f to whatever is inside in the way sees

    fit, then flattens the result (presumably a nested ) into a single flat of the same kind. (flatmap f )
  18. map