Underscore
-
Upload
brian-lonsdorf -
Category
Technology
-
view
13.119 -
download
1
Transcript of Underscore
“Hey Underscore, You’re doing it
wrong”
I <3 _
So what’s wrong then?
Agenda
•Currying
•Composition
•Functors
•Random stuff
CurryingCurrying
Curried Function
“A function that will return a new function until it receives all it’s arguments”
...weird
Wu.js to the rescue!
(well, one function at least)
not weird
ExampleExample
ExampleFunction
alUnderscor
e
0 0
ExampleFunction
alUnderscor
e
1 0
ExampleFunction
alUnderscor
e
2 0
ExampleFunction
alUnderscor
e
3 0
underscore’s api prevents you from currying
Currying•Make generic functions - data is
gone
•Build new functions by applying args
•Much more concise definitions
•Make types “line up” for composition
CompositionComposition
Category Theory
“The mathematical theory of transforming values and crap”
*inaccurate definition
ExampleExample
ExampleFunction
alUnderscor
e
3 0
ExampleFunction
alUnderscor
e
4 0
ExampleFunction
alUnderscor
e
5 0
underscore promotes chain as the function
of choice.
Composition•Build new functions from other
functions
•Helps build generic programs w/o args
•Extremely high level coding
•Mathematically backed
FunctorsFunctors
ExampleExample
ExampleFunction
alUnderscor
e
5 0
ExampleFunction
alUnderscor
e
6 0
ExampleFunction
alUnderscor
e
7 0
underscore explicitly prevents
extending map
Functors/Typeclasses
•Change behavior without altering function open/closed principle
•Not just map - reduce, compose, etc
•Intuition and “non proprietary” api
•Free formulas
•Dynamic type safety?
In conclusionIn conclusion