3 <link rel=
"stylesheet" href=
"css/csshake.min.css">
4 <link href=
"https://fonts.googleapis.com/css?family=Press+Start+2P&display=swap" rel=
"stylesheet">
6 href=
"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/styles/atom-one-dark.min.css">
7 <script src=
"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/highlight.min.js"></script>
8 <script>hljs.initHighlightingOnLoad();
</script>
9 <title>Crazy Wide-Eyed Functional Programming
</title>
13 font-family: 'Press Start
2P', cursive;
17 background-color: #f98012;
18 background-image: url(
"img/tile.png");
19 background-repeat: repeat;
21 image-rendering: crisp-edges;
22 background-position-x: -
33px;
23 background-blend-mode: multiply;
33 letter-spacing: -
20px;
34 transform: rotate(
90deg) scale(
1,
1.5);
42 font-family: 'Press Start
2P', cursive;
43 text-shadow:
2px
2px
0 #
000;
49 text-shadow:
2px
2px
0 #
000;
55 text-shadow:
10px
10px
0 #
00000069;
61 box-shadow:
10px
10px
0 #
00000069;
64 background: #
6187a8e3;
69 justify-content: center;
77 justify-content: center;
84 text-shadow:
2px
2px
0 #
000;
97 image-rendering: optimizeSpeed; /* STOP SMOOTHING, GIVE ME SPEED */
98 image-rendering: -moz-crisp-edges; /* Firefox */
99 image-rendering: -o-crisp-edges; /* Opera */
100 image-rendering: -webkit-optimize-contrast; /* Chrome (and eventually Safari) */
101 image-rendering: pixelated; /* Chrome */
102 image-rendering: optimize-contrast; /* CSS3 Proposed */
103 -ms-interpolation-mode: nearest-neighbor; /* IE8+ */
110 #slide-
1 .shake-constant, .crazy, .span {
111 display: inline-block;
114 #slide-
1 .shake-opacity {
126 box-shadow:
10px
10px
0 #
00000069;
127 border:
2px solid black;
128 background-color: #
3f6382;
133 box-shadow:
10px
10px
0 #
00000069;
134 border:
2px solid black;
141 span[class^=
"code-friends"].on, span[class^=
"code-friends"].on
> span, span[class^=
"code-friends"].on
> span
> span {
142 color: #f98012 !important;
145 span[class^=
"promise"].on, span[class^=
"promise"].on
> span, span[class^=
"promise"].on
> span
> span, span[class^=
"promise"].on
> span
> span
> span {
146 color: #f98012 !important;
162 <div style=
"height: 20%; text-align: center;">
163 <img style=
"height: 100%; display: block; margin-left: auto; margin-right: auto; margin-bottom: 10px;" src=
"img/cloudguy.gif" />
164 <div id=
"cgquotes" style=
"width: 80%; margin: auto;">Welcome to the talk!
</div>
169 <div class=
"slide-title">=<< What's up with that Title?
>>=
</div>
170 <div class=
"slide flexotron">
171 <div style=
"justify-content: right;">
172 <img class=
"shake-constant shake" src=
"img/wide-eyed-crazy.png" style=
"width: 70%; margin-right: 10%;">
174 <div style=
"justify-content: left">
175 <div style=
"display: flex; align-items: center; width: 70%">
176 <div id=
"rant" class=
"textbox" style=
"display: block;height: auto; width:100%; margin-left:10%;">
177 <span class=
"crazy">It’s functions,
</span><span class=
"shake-constant shake-opacity">pure
</span><span class=
"crazy"> functions! Pure functions and their values, PURE FUNCTIONS FOREVER AND FOREVER AND FOREVER A HUNDRED YEARS
</span><span class=
"shake-constant shake-opacity">monad
</span><span class=
"crazy">... some... things... Me and
</span><span class=
"shake-constant shake-opacity">monads
</span><span class=
"crazy"> runnin' around and...
</span><span class=
"shake-constant shake-opacity">applicative functor
</span><span class=
"crazy"> time... a- all day long forever... All a - a hundred days
</span><span class=
"shake-constant shake-opacity">applicatives
</span><span class=
"crazy"> and
</span><span class=
"shake-constant shake-opacity">functors
</span><span class=
"crazy">! Forever a hundred times.... OVER and over
</span><span class=
"shake-constant shake-opacity">monad transformers
</span><span class=
"crazy">... adventures dot com... W W W dot at
</span><span class=
"shake-constant shake-opacity">lambda calculus
</span><span class=
"crazy"> and
</span><span class=
"shake-constant shake-opacity">category theory
</span><span class=
"crazy"> dot com w..w..w... function composition adventures... Ah- hundred years… Every minute
</span><span class=
"shake-constant shake-opacity">referential... transparency
</span><span class=
"crazy"> dot com.... w w w a hundred times...
</span><span class=
"shake-constant shake-opacity">composition
</span><span class=
"crazy"> dot com...
</span>
181 <div class=
"fig">Fig
1.1 What most people thing a typical functional programming advocate looks like
</div>
185 <div class=
"slide-title">=<< Obligatory Quote
>>=
</div>
190 <div class=
"slide-title">=<< Obligatory Quote
>>=
</div>
191 <div class=
"slide flexotron">
192 <div class=
"textbox">If you wish to build a ship, do not divide the men into teams and send them to the forest to cut wood. Instead, teach them to long for the vast and endless sea.
</div>
196 <div class=
"slide-title">=<< Obligatory Quote
>>=
</div>
197 <div class=
"slide flexotron">
198 <div class=
"textbox">If you wish to build a ship, do not divide the men into teams and send them to the forest to cut wood. Instead, teach them to long for the vast and endless sea.
<br /><br /> - Some French Guy. Idk. Who cares, I'm not cultured. I'm Australian.
</div>
202 <div class=
"slide-title">=<< What is this Talk About?
>>=
</div>
207 <div class=
"slide-title">=<< What is this Talk About?
>>=
</div>
208 <div class=
"slide flexotron">
209 <div style=
"text-align:center; font-size:60px; text-shadow: 4px 4px #000; padding:20px;" >Perspective
</div>
213 <div class=
"slide-title">=<< What is Functional Programming?
>>=
</div>
214 <div class=
"slide flexotron">
215 <div style=
"text-align:center; font-size:60px; text-shadow: 4px 4px #000; padding:20px;" >Programming with functions.
</div>
219 <div class=
"slide-title">=<< What is a Function?
>>=
</div>
220 <div class=
"slide flexotron">
221 <div style=
"text-align:center; font-size:60px; text-shadow: 4px 4px #000; padding:20px;" >A mapping between sets that associates every element of the first set to exactly one element of the second set.
</div>
225 <div class=
"slide-title">=<< Huh?
>>=
</div>
227 <h1>Why would you wanna do that?!
</h1>
231 <div class=
"slide-title">=<< Huh?
>>=
</div>
233 <h1>Why would you wanna do that?!
</h1>
234 <div class=
"textbox" style=
"width: 60%; margin: auto; text-align: left;">
236 <li>Learning is good
</li>
237 <li>Brain plasticity
</li>
238 <li>Greater perspective
</li>
244 <div class=
"slide-title">=<< Paradigms
>>=
</div>
245 <div class=
"slide flexotron">
246 <div style=
"text-align:center; font-size:60px; text-shadow: 4px 4px #000; padding:20px;" >Paradigms
</div>
250 <div class=
"slide-title">=<< Paradigms
>>=
</div>
251 <div class=
"slide flexotron">
252 <div class=
"textbox flexotron" style=
"position: relative; width: 30%; height: 50%; margin-right:20px;">
253 <span class=
"textbox" style=
"box-shadow: none; position: absolute; top: -20px; left: 30px;">Declarative
</span>
254 <div class=
"textbox" style=
"position: relative; width: 80%; height: 60%;">
255 <span class=
"textbox" style=
"box-shadow: none; position: absolute; top: -20px; left: 30px;">Functional
</span>
256 <ul style=
"text-align: left; margin-top: 65px;margin-left: 40px;">
264 <div class=
"textbox flexotron" style=
"position: relative; width: 30%; height: 50%; margin-right:20px;">
265 <span class=
"textbox" style=
"box-shadow: none; position: absolute; top: -20px; left: 30px;">Imperative
</span>
266 <div class=
"textbox" style=
"position: relative; width: 80%; height: 60%;">
267 <span class=
"textbox" style=
"box-shadow: none; position: absolute; top: -20px; left: 30px;">Procedural
</span>
268 <ul style=
"text-align: left; margin-top: 65px;margin-left: 40px;">
279 <div class=
"slide-title">=<< Gramatical Mood
>>=
</div>
280 <div class=
"slide flexotron">
281 <div class=
"textbox" style=
"position: relative; width: 30%; height: 50%; margin-right:20px; padding-top: 40px;">
282 <span class=
"textbox" style=
"box-shadow: none; position: absolute; top: -20px; left: 30px;">Declarative
</span>
283 A sentence which expresses a statement of fact.
284 <ul style=
"text-align: left; margin-top: 65px;margin-left: 40px;">
286 <li>I like climbing.
</li>
287 <li>Ice is cold.
</li>
288 <li>Mathieu is shredded.
</li>
291 <div class=
"textbox" style=
"position: relative; width: 30%; height: 50%; margin-right:20px; padding-top: 40px;">
292 <span class=
"textbox" style=
"box-shadow: none; position: absolute; top: -20px; left: 30px;">Imperative
</span>
293 <span>A sentence which expresses instructions, or requests.
</span>
294 <ul style=
"text-align: left; margin-top: 65px;margin-left: 40px;">
295 <li>Shut the door.
</li>
296 <li>Don't eat my burger.
</li>
297 <li>Let's go to the pub.
</li>
298 <li>Don't make eye contact with Mathieu.
</li>
304 <div class=
"slide-title">=<< Gramatical Mood
>>=
</div>
305 <div class=
"slide flexotron">
306 <div class=
"textbox flexotron" style=
"position: relative; width: 30%; height: 50%; margin-right:20px; padding-top: 40px;">
307 <span class=
"textbox" style=
"box-shadow: none; position: absolute; top: -20px; left: 30px;">Declarative
</span>
310 <div class=
"textbox flexotron" style=
"position: relative; width: 30%; height: 50%; margin-right:20px; padding-top: 40px;">
311 <span class=
"textbox" style=
"box-shadow: none; position: absolute; top: -20px; left: 30px;">Imperative
</span>
317 <div class=
"slide-title">=<< Big Brain Moment
>>=
</div>
318 <div class=
"slide flexotron">
319 <div class=
"textbox" style=
"text-align:center; font-size:40px; text-shadow: 4px 4px #000; padding:20px;" >Programming languages
<span class=
"shake-slow shake-constant" style=
"color: #f98012">ARE
</span> human languages.
</div>
323 <div class=
"slide-title">=<< Why is declaritive mood good?
>>=
</div>
328 <div class=
"slide-title">=<< Why is declaritive mood good?
>>=
</div>
329 <div class=
"slide flexotron">
330 <div style=
"text-align:center; font-size:60px; text-shadow: 4px 4px #000; padding:20px;" >Atemporality
</div>
334 <div class=
"slide-title">=<< Why is declaritive mood good?
>>=
</div>
335 <div class=
"slide flexotron">
336 <div style=
"text-align:center; font-size:60px; text-shadow: 4px 4px #000; padding:20px;" >Independant of or unaffected by time.
</div>
340 <div class=
"slide-title">=<< Why is declaritive mood good?
>>=
</div>
341 <div class=
"slide flexotron">
342 <div style=
"text-align:center; font-size:50px; text-shadow: 4px 4px #000; padding:20px;" >Declarative programs express what
<span class=
"shake-slow shake-constant" style=
"color: #f98012">they actually do
</span> Leaving more
"brain space" to focus on solving the problem.
</div>
346 <div class=
"slide-title">=<< To Recap
>>=
</div>
348 <h2>Why would you wanna do that?
</h2>
349 <div class=
"textbox" style=
"width: 60%; margin: auto; text-align: left;">
351 <li>Because sometimes there is such a thing as too much freedom
</li>
352 <li>Functional programming is awesome because it stops you shooting yourself in the foot
</li>
353 <li>"Constraints liberate, liberties constrain"</li>
359 <div class=
"slide-title">=<< Some Code (Finally)
>>=
</div>
364 <div class=
"slide-title">=<< Some Code (Finally)
>>=
</div>
365 <div class=
"slide flexotron">
366 <div style=
"text-align:center; font-size:50px; text-shadow: 4px 4px #000; padding:20px;" >Enough of this philosophy and linguistics mumbo jumbo, already!
</div>
370 <div class=
"slide-title">=<< Some Code (Finally)
>>=
</div>
372 <h1>The Great Dividers
</h1>
374 <div style=
"display: flex;">
375 <pre style=
"margin: auto;"><code style=
"font-size: 20px;"><span class=
"code-friends1 code-friends4">x = x +
1;
</span></code></pre>
377 <div style=
"display: flex; margin-top: 20px; margin-bottom: 20px;">
378 <span style=
"margin: auto;">and:
</span>
380 <div style=
"display: flex; margin-bottom:50px;">
381 <pre style=
"margin: auto;"><code style=
"font-size: 20px;"><span class=
"code-friends2 code-friends3">function repeat(x) {
382 return x + repeat(x);
383 }
</span></code></pre>
385 <h2>OK, so what?
</h2>
386 <div style=
"display: flex;">
387 <div class=
"textbox" style=
"margin: auto; width: 60%; font-size: 20px;">In the declaritive paradigm,
<span class=
"code-friends1" onmouseenter=
"activateFriends(1);" onmouseleave=
"deactivateFriends(1);" style=
"display: inline-block;">this
</span> code hangs while
<span class=
"code-friends2" onmouseenter=
"activateFriends(2);" onmouseleave=
"deactivateFriends(2);" style=
"display: inline-block;">this
</span> code runs. In the imperative paradigm
<span class=
"code-friends3" onmouseenter=
"activateFriends(3);" onmouseleave=
"deactivateFriends(3);" style=
"display: inline-block;">this
</span> code hangs, while
<span class=
"code-friends4" onmouseenter=
"activateFriends(4);" onmouseleave=
"deactivateFriends(4);" style=
"display: inline-block;">this
</span> code runs.
</div>
392 <div class=
"slide-title">=<< Some Code (Finally)
>>=
</div>
394 <div style=
"display: flex; margin-top: 50px;">
395 <pre style=
"margin: auto;"><code style=
"font-size: 20px;">x = x +
1;
</code></pre>
397 <div class=
"flexotron" style=
"height: 80%;">
398 <div class=
"textbox" style=
"position: relative; width: 30%; height: 50%; margin-right:20px; padding-top: 40px;">
399 <span class=
"textbox" style=
"box-shadow: none; position: absolute; top: -20px; left: 30px;">Declarative
</span>
400 "x is the same as itself plus one."<br /><br /><br /><br /><br />
403 <div class=
"textbox" style=
"position: relative; width: 30%; height: 50%; margin-right:20px; padding-top: 40px;">
404 <span class=
"textbox" style=
"box-shadow: none; position: absolute; top: -20px; left: 30px;">Imperative
</span>
405 "Evaluate the thing on the right of `=` then store it in the thing on the left of `=`."<br /><br /><br />
406 A list of instructions that can be followed.
412 <div class=
"slide-title">=<< Some Code (Finally)
>>=
</div>
414 <div style=
"display: flex; margin-top: 50px;">
415 <pre style=
"margin: auto;"><code style=
"font-size: 20px;">function repeat(x) {
416 return x + repeat(x);
419 <div class=
"flexotron" style=
"height: 80%;">
420 <div class=
"textbox" style=
"position: relative; width: 30%; height: 50%; margin-right:20px; padding-top: 30px;">
421 <span class=
"textbox" style=
"box-shadow: none; position: absolute; top: -20px; left: 30px;">Declarative
</span>
422 "The repeat of `x` is `x` appended to the repeat of `x`"<br /><br /><br />
423 An infinite list of `x`!
425 <div class=
"textbox" style=
"position: relative; width: 30%; height: 50%; margin-right:20px; padding-top: 40px;">
426 <span class=
"textbox" style=
"box-shadow: none; position: absolute; top: -20px; left: 30px;">Imperative
</span>
427 "To evaluate the repeate of `x`, first evaluate the repeat of `x`"<br /><br /><br />
428 ...Yeah, you see the problem?
434 <div class=
"slide-title">=<< Big Brain Moment
>>=
</div>
435 <div class=
"slide flexotron">
436 <div class=
"textbox" style=
"text-align:center; font-size:40px; text-shadow: 4px 4px #000; padding:20px;" >Programming languages
<span class=
"shake-slow shake-constant" style=
"color: #f98012">ARE
</span> human languages.
</div>
440 <div class=
"slide-title">=<< Some Code (Finally)
>>=
</div>
442 <h1>Real Haskell Code That Runs
</h1>
443 <pre><code class=
"haskell">repeat x = x ++ repeat x
444 threeFs = take
3 (repeat
"f")
451 <div class=
"slide-title">=<< Some Code (Finally)
>>=
</div>
453 <h1>Real JavaScript Code That Hangs
</h1>
454 <pre><code class=
"javascript">function repeat(x) {
455 return x + repeat(x);
458 threeFs = repeat(
"f").substr(
0,
3);
460 > InternalError: too much recursion
465 <div class=
"slide-title">=<< Promises
>>=
</div>
466 <div class=
"slide flexotron">
467 <div style=
"position: relative; text-align:center; font-size:40px; text-shadow: 4px 4px #000;" >
468 <div class=
"angereyWrap"><div class=
"angerey">>:(
</div></div>
469 <div class=
"angereyWrap"><div class=
"angerey">>:(
</div></div>
470 <div class=
"angereyWrap"><div class=
"angerey">>:(
</div></div>
471 <div class=
"angereyWrap"><div class=
"angerey">>:(
</div></div>
472 <div class=
"angereyWrap"><div class=
"angerey">>:(
</div></div>
473 <div class=
"angereyWrap"><div class=
"angerey">>:(
</div></div>
474 <div class=
"angereyWrap"><div class=
"angerey">>:(
</div></div>
475 <div class=
"angereyWrap"><div class=
"angerey">>:(
</div></div>
476 <div class=
"angereyWrap"><div class=
"angerey">>:(
</div></div>
477 <div class=
"angereyWrap"><div class=
"angerey">>:(
</div></div>
478 Promises
<span class=
"shake-slow shake-constant" style=
"display: inline-block; color: #f98012">do not
</span> make things asynchronous!
</div>
482 <div class=
"slide-title">=<< Promises
>>=
</div>
484 <h2>What problems do promises solve?
</h2>
485 <div class=
"textbox" style=
"width: 60%; margin: auto; text-align: left;">
487 <li>Asynchronous request management
</li>
488 <li>Error handling for computations which may fail
</li>
489 <li>Probably more too
</li>
492 <h2 style=
"margin-top: 50px;">What are promises then?
</h2>
493 <div class=
"textbox" style=
"width: 60%; margin: auto; text-align: left;">
495 <li>A value (which may or may not be available yet) wrapped in some additional context
</li>
496 <li>Functions to instantiate the wrapper (Promise.resolve, Promise.reject)
497 <li>A rule for composing these wrapped values (then)
</li>
503 <div class=
"slide-title">=<< Promises
>>=
</div>
505 <h1>Terminology/syntax recap
</h1>
506 <h2>JavaScript arrow functions
</h2>
507 <div style=
"display: flex;">
508 <pre style=
"margin: auto;"><code style=
"font-size: 20px;">x =
> x +
1;
</code></pre>
510 <div style=
"display: flex; margin-top: 20px; margin-bottom: 20px;">
511 <span style=
"margin: auto;">is equivalent to:
</span>
513 <div style=
"display: flex; margin-bottom:50px;">
514 <pre style=
"margin: auto;"><code style=
"font-size: 20px;">function(x) {
519 <div style=
"display: flex;">
520 <div class=
"textbox" style=
"margin: auto; width: 60%; font-size: 20px;">A method of combining two things of the same type in to another thing that is also of the same type
</div>
525 <div class=
"slide-title">=<< Promises
>>=
</div>
527 <h1>Promise composition
</h1>
528 <div style=
"display: flex;">
529 <div class=
"textbox" style=
"margin: auto; width: 60%; font-size: 20px;">The `then` method of a promise accepts a function as an argument. This function takes a value and returns a new promise. The new promise
"combines" the previous two using the
"composition rule" given to `then`.
</div>
531 <div style=
"display: flex; margin-top: 100px">
532 <pre style=
"margin: auto;"><code style=
"font-size: 12px;"><span class=
"promise3"><span class=
"promise2"><span class=
"promise1">Promise.resolve(
"Some value")
</span>.then(x =
> Promise.resolve(x +
" and another value"))
</span>.then(x =
> Promise.resolve(x +
" and another one!"))
</span>;
</code></pre>
534 <div style=
"display: flex;">
535 <div class=
"textbox" style=
"margin: auto; width: 60%; font-size: 20px; margin-top: 50px;">There are three promises in the above snippet.
<span onmouseenter=
"activatePromise(1)" onmouseleave=
"deactivatePromise(1)" class=
"promise1">One
</span>,
<span onmouseenter=
"activatePromise(2)" onmouseleave=
"deactivatePromise(2)" class=
"promise2">two
</span>,
<span onmouseenter=
"activatePromise(3)" onmouseleave=
"deactivatePromise(3)" class=
"promise3">three
</span>.
</div>
537 <div style=
"display: flex; margin-top: 100px">
538 <pre style=
"margin: auto;"><code style=
"font-size: 12px;">Promise.resolve(
"Some value").then(x =
> Promise.reject(
"It's all gone wrong")).then(x =
> Promise.resolve(x +
" and another one!"));
</code></pre>
540 <div style=
"display: flex;">
541 <div class=
"textbox" style=
"margin: auto; width: 60%; font-size: 20px; margin-top: 50px;">The above snippet still results in a promise, but it is a
"failed" one. Any subsequent `then` after the `reject` has no effect.
</div>
546 <div class=
"slide-title">=<< Promises
>>=
</div>
548 <h1>OK great but who cares?
</h1>
549 <div class=
"textbox" style=
"width: 60%; margin: auto; text-align: left;">
551 <li>We are
<span class=
"shake-constant shake-opacity highlight" style=
"display: inline-block;">declaring
</span> how we want promises to compose
</li>
553 The order that the promises actually resolve their values in is not important
554 <ul><li>In other words, we don't have to worry about
<span class=
"shake-constant shake-opacity highlight" style=
"display: inline-block;">timing
</span> anymore
</li></ul>
556 <li>We can
<span class=
"shake-constant shake-opacity highlight" style=
"display: inline-block;">declare
</span> a failure anywhere in the chain
</li>
562 <div class=
"slide-title">=<< Promises
>>=
</div>
563 <div class=
"slide flexotron">
564 <div style=
"position: relative;">
565 <img src=
"img/thonking.gif" />
566 <div class=
"thonkingWrap"><div class=
"thonk">atemporality?
</div></div>
567 <div class=
"thonkingWrap"><div class=
"thonk">declaritive?
</div></div>
568 <div class=
"thonkingWrap"><div class=
"thonk">functions?
</div></div>
569 <div class=
"thonkingWrap"><div class=
"thonk">composition?
</div></div>
574 <div class=
"slide-title">=<< Promises
>>=
</div>
578 <pre style=
"margin-bottom: 50px;"><code class=
"javascript"><span class=
"code-friends1" onmouseenter=
"activateFriends(1);" onmouseleave=
"deactivateFriends(1);" style=
"display: inline-block">Promise.resolve
</span>(
<span class=
"code-friends2" onmouseenter=
"activateFriends(2);" onmouseleave=
"deactivateFriends(2);" style=
"display: inline-block">"We start here"</span>)
579 <span class=
"code-friends3" onmouseenter=
"activateFriends(3);" onmouseleave=
"deactivateFriends(3);" style=
"display: inline-block">.then
</span>(
<span class=
"code-friends4" onmouseenter=
"activateFriends(4);" onmouseleave=
"deactivateFriends(4);" style=
"display: inline-block">x =
></span> <span class=
"code-friends5" onmouseenter=
"activateFriends(5);" onmouseleave=
"deactivateFriends(5);" style=
"display: inline-block">Promise.resolve
</span>(
<span class=
"code-friends6" onmouseenter=
"activateFriends(6);" onmouseleave=
"deactivateFriends(6);" style=
"display: inline-block">x +
" then get here"</span>))
580 <span class=
"code-friends7" onmouseenter=
"activateFriends(7);" onmouseleave=
"deactivateFriends(7);" style=
"display: inline-block">.then
</span>(
<span class=
"code-friends8" onmouseenter=
"activateFriends(8);" onmouseleave=
"deactivateFriends(8);" style=
"display: inline-block">x =
></span> <span class=
"code-friends9" onmouseenter=
"activateFriends(9);" onmouseleave=
"deactivateFriends(9);" style=
"display: inline-block">Promise.resolve
</span>(
<span class=
"code-friends10" onmouseenter=
"activateFriends(10);" onmouseleave=
"deactivateFriends(10);" style=
"display: inline-block">x +
" and finally here!"</span>))
</code></pre>
582 <pre><code class=
"haskell"><span class=
"code-friends1" onmouseenter=
"activateFriends(1);" onmouseleave=
"deactivateFriends(1);" style=
"display: inline-block">Right
</span>(
<span class=
"code-friends2" onmouseenter=
"activateFriends(2);" onmouseleave=
"deactivateFriends(2);" style=
"display: inline-block">"We start here"</span>)
583 <span class=
"code-friends3" onmouseenter=
"activateFriends(3);" onmouseleave=
"deactivateFriends(3);" style=
"display: inline-block">>>=
</span> (
<span class=
"code-friends4" onmouseenter=
"activateFriends(4);" onmouseleave=
"deactivateFriends(4);" style=
"display: inline-block">\x -
> </span><span class=
"code-friends5" onmouseenter=
"activateFriends(5);" onmouseleave=
"deactivateFriends(5);" style=
"display: inline-block">Right
</span> (
<span class=
"code-friends6" onmouseenter=
"activateFriends(6);" onmouseleave=
"deactivateFriends(6);" style=
"display: inline-block">x ++
" then get here"</span>))
584 <span class=
"code-friends7" onmouseenter=
"activateFriends(7);" onmouseleave=
"deactivateFriends(7);" style=
"display: inline-block">>>=
</span> (
<span class=
"code-friends8" onmouseenter=
"activateFriends(8);" onmouseleave=
"deactivateFriends(8);" style=
"display: inline-block">\x -
></span> <span class=
"code-friends9" onmouseenter=
"activateFriends(9);" onmouseleave=
"deactivateFriends(9);" style=
"display: inline-block">Right
</span> (
<span class=
"code-friends10" onmouseenter=
"activateFriends(10);" onmouseleave=
"deactivateFriends(10);" style=
"display: inline-block">x ++
" and finally here!"</span>))
</code></pre>
588 <div class=
"slide-title">=<< Promises
>>=
</div>
592 <pre style=
"margin-bottom: 50px;"><code class=
"javascript"><span class=
"code-friends1" onmouseenter=
"activateFriends(1);" onmouseleave=
"deactivateFriends(1);" style=
"display: inline-block">Promise.resolve
</span>(
<span class=
"code-friends2" onmouseenter=
"activateFriends(2);" onmouseleave=
"deactivateFriends(2);" style=
"display: inline-block">"We start here"</span>)
593 <span class=
"code-friends3" onmouseenter=
"activateFriends(3);" onmouseleave=
"deactivateFriends(3);" style=
"display: inline-block">.then
</span>(
<span class=
"code-friends4" onmouseenter=
"activateFriends(4);" onmouseleave=
"deactivateFriends(4);" style=
"display: inline-block">x =
></span> <span class=
"code-friends5" onmouseenter=
"activateFriends(5);" onmouseleave=
"deactivateFriends(5);" style=
"display: inline-block">Promise.resolve
</span>(
<span class=
"code-friends6" onmouseenter=
"activateFriends(6);" onmouseleave=
"deactivateFriends(6);" style=
"display: inline-block">x +
" then get here"</span>))
594 <span class=
"code-friends11" onmouseenter=
"activateFriends(11);" onmouseleave=
"deactivateFriends(11);" style=
"display: inline-block">.then
</span>(
<span class=
"code-friends12" onmouseenter=
"activateFriends(12);" onmouseleave=
"deactivateFriends(12);" style=
"display: inline-block">x =
></span> <span class=
"code-friends13" onmouseenter=
"activateFriends(13);" onmouseleave=
"deactivateFriends(13);" style=
"display: inline-block">Promise.reject
</span>(
<span class=
"code-friends14" onmouseenter=
"activateFriends(14);" onmouseleave=
"deactivateFriends(14);" style=
"display: inline-block">"Oh noes!"</span>))
595 <span class=
"code-friends7" onmouseenter=
"activateFriends(7);" onmouseleave=
"deactivateFriends(7);" style=
"display: inline-block">.then
</span>(
<span class=
"code-friends8" onmouseenter=
"activateFriends(8);" onmouseleave=
"deactivateFriends(8);" style=
"display: inline-block">x =
></span> <span class=
"code-friends9" onmouseenter=
"activateFriends(9);" onmouseleave=
"deactivateFriends(9);" style=
"display: inline-block">Promise.resolve
</span>(
<span class=
"code-friends10" onmouseenter=
"activateFriends(10);" onmouseleave=
"deactivateFriends(10);" style=
"display: inline-block">x +
" and finally here!"</span>))
</code></pre>
597 <pre><code class=
"haskell"><span class=
"code-friends1" onmouseenter=
"activateFriends(1);" onmouseleave=
"deactivateFriends(1);" style=
"display: inline-block">Right
</span>(
<span class=
"code-friends2" onmouseenter=
"activateFriends(2);" onmouseleave=
"deactivateFriends(2);" style=
"display: inline-block">"We start here"</span>)
598 <span class=
"code-friends3" onmouseenter=
"activateFriends(3);" onmouseleave=
"deactivateFriends(3);" style=
"display: inline-block">>>=
</span> (
<span class=
"code-friends4" onmouseenter=
"activateFriends(4);" onmouseleave=
"deactivateFriends(4);" style=
"display: inline-block">\x -
> </span><span class=
"code-friends5" onmouseenter=
"activateFriends(5);" onmouseleave=
"deactivateFriends(5);" style=
"display: inline-block">Right
</span> (
<span class=
"code-friends6" onmouseenter=
"activateFriends(6);" onmouseleave=
"deactivateFriends(6);" style=
"display: inline-block">x ++
" then get here"</span>))
599 <span class=
"code-friends11" onmouseenter=
"activateFriends(11);" onmouseleave=
"deactivateFriends(11);" style=
"display: inline-block">>>=
</span> (
<span class=
"code-friends12" onmouseenter=
"activateFriends(12);" onmouseleave=
"deactivateFriends(12);" style=
"display: inline-block">\x -
></span> <span class=
"code-friends13" onmouseenter=
"activateFriends(13);" onmouseleave=
"deactivateFriends(13);" style=
"display: inline-block">Left
</span>(
<span class=
"code-friends14" onmouseenter=
"activateFriends(14);" onmouseleave=
"deactivateFriends(14);" style=
"display: inline-block">"Oh noes!"</span>))
600 <span class=
"code-friends7" onmouseenter=
"activateFriends(7);" onmouseleave=
"deactivateFriends(7);" style=
"display: inline-block">>>=
</span> (
<span class=
"code-friends8" onmouseenter=
"activateFriends(8);" onmouseleave=
"deactivateFriends(8);" style=
"display: inline-block">\x -
></span> <span class=
"code-friends9" onmouseenter=
"activateFriends(9);" onmouseleave=
"deactivateFriends(9);" style=
"display: inline-block">Right
</span> (
<span class=
"code-friends10" onmouseenter=
"activateFriends(10);" onmouseleave=
"deactivateFriends(10);" style=
"display: inline-block">x ++
" and finally here!"</span>))
</code></pre>
605 var div, i, j, span, duration =
"";
608 div = document.querySelectorAll(
"#rant > span.crazy");
609 for (j =
0; j < div.length; j++) {
611 for (i =
0; i < div[j].innerText.length; i++) {
612 duration = Math.floor(Math.random() *
5) +
100
613 span +=
"<span class=\"letter shake-constant shake-little\" style=\"animation-duration: " + duration +
"ms\">";
614 span += div[j].innerText[i] ==
" " ?
" " : div[j].innerText[i];
617 crazyTexts.push(span);
620 opacities = document.querySelectorAll(
"#rant > span.shake-opacity");
621 for (k =
0; k < opacities.length; k++) {
623 opacities[k].style.animationDuration = shrek + 's';
624 opacyTexts.push(opacities[k].outerHTML);
628 for (l =
0; l< crazyTexts.length; l++) {
629 allText+=crazyTexts[l] + (opacyTexts[l] ? opacyTexts[l] :
"");
632 document.getElementById('rant').innerHTML = allText;
636 var b = document.querySelectorAll('body')[
0];
637 setInterval(function(){
640 b.style.backgroundPosition = x + 'px ' + y + 'px';
643 urlParts = document.URL.split('#');
644 window.console.log(urlParts);
645 var currentSlide = urlParts.length
> 1 ? urlParts[
1] :
0;
646 document.getElementById('slide-' + currentSlide).style.display = 'block';
647 document.onkeydown = checkKey;
649 function checkKey(e) {
651 e = e || window.event;
652 if (e.keyCode == '
37') {
653 if (document.getElementById('slide-' + currentSlide)) {
654 document.getElementById('slide-' + currentSlide).style.display = 'none';
657 document.getElementById('slide-' + currentSlide).style.display = 'block';
659 else if (e.keyCode == '
39') {
660 if (document.getElementById('slide-' + currentSlide)) {
661 document.getElementById('slide-' + currentSlide).style.display = 'none';
664 document.getElementById('slide-' + currentSlide).style.display = 'block';
667 console.log(currentSlide);
671 function activateFriends(n) {
672 f = document.querySelectorAll('.code-friends' + n);
674 for (fr =
0; fr< f.length; fr++) {
675 f[fr].classList.add(
"shake-constant");
676 f[fr].classList.add(
"shake-slow");
677 f[fr].classList.add(
"on");
681 function deactivateFriends(n) {
682 f = document.querySelectorAll('.code-friends' + n);
683 for (fr =
0; fr< f.length; fr++) {
684 f[fr].classList.remove(
"shake-constant");
685 f[fr].classList.remove(
"shake-slow");
686 f[fr].classList.remove(
"on");
690 function activatePromise(n) {
691 p = document.querySelectorAll('.promise' + n);
692 for (fr =
0; fr< p.length; fr++) {
693 p[fr].classList.add('on');
697 function deactivatePromise(n) {
698 p = document.querySelectorAll('.promise' + n);
699 for (fr =
0; fr< p.length; fr++) {
700 p[fr].classList.remove('on');
705 "Welcome to the talk!",
706 "I hope we'll have fun exploring functional programming together!",
707 "But while we wait let's share interesting facts and anectodes :)",
708 "If you can be disgruntled, can you also be gruntled?",
709 "0.9 recurring is exactly equal to one if you think about it.",
710 "In English, the word \"ghoti\" can be pronounced as \"fish\".",
711 "Your credit card details are somewhere in Pi.",
712 "It takes 366 people to make sure two of them share a birthday, but only 23 people to ensure a 50% chance.",
713 "1729 is the best number (I checked them all).",
714 "The secret to strengh is to eat only a banana for breakfast.",
715 "All of Back to the Future happened in the past.",
716 "Everything is in the future."
719 cgq = document.getElementById(
"cgquotes");
720 numQuotes = cloudGuyQuotes.length;
722 setInterval(function(){
723 if (currentQuote ==
0 || currentQuote ==
1) {
726 currentQuote = Math.floor(Math.random()*(cloudGuyQuotes.length -
3)) +
3;
727 console.log(currentQuote);
730 cgq.innerText = cloudGuyQuotes[currentQuote];
733 angeries = document.querySelectorAll(
".angereyWrap");
735 shakes = [
"shake",
"shake-hard",
"shake-slow",
"shake-little",
"shake-horizontal",
"shake-vertical",
"shake-rotate",
"shake-opacity",
"shake-crazy",
"shake-chunk"];
736 for (a =
0; a < angeries.length; a++) {
737 randomness = (Math.round(Math.random() *
10) +
1) * -
10;
738 angeries[a].style.top = ((a
> 4) ? (-
180-randomness) : (
180 + randomness)) +
"%" ;
739 thing = ((Math.floor(Math.random() *
10) +
1) *
9) +
"%";
741 while (usedPositions.includes(thing)) {
742 thing = ((Math.floor(Math.random() *
10) +
1) *
9) +
"%";
745 angeries[a].style.left = thing;
746 angeries[a].classList.add(
"shake-constant");
747 angeries[a].classList.add(shakes[Math.floor(Math.random()*shakes.length)]);
748 usedPositions.push(thing);
751 thonkings = document.querySelectorAll(
".thonkingWrap");
752 shakes = [
"shake-slow",
"shake-little",
"shake-opacity"];
754 for (a =
0; a < thonkings.length; a++) {
755 thing = Math.floor(Math.random() *
4) +
1;
756 randomnessX = -(Math.round(Math.random() *
100) +
1);
757 randomnessY = -(Math.round(Math.random() *
50) +
1);
759 while (usedPositions.includes(thing)) {
760 thing = Math.floor(Math.random() *
4) +
1;
765 thonkings[a].style.left = randomnessX + 'px';
766 thonkings[a].style.top = randomnessY + 'px';
767 thonkings[a].children[
0].style.transform = 'rotate(-
40deg) scale(
1,
1.5)'
768 thonkings[a].classList.add(
"shake-constant");
769 thonkings[a].classList.add(shakes[Math.floor(Math.random()*shakes.length)]);
772 thonkings[a].style.right = randomnessX + 'px';
773 thonkings[a].style.top = randomnessY + 'px';
774 thonkings[a].classList.add(
"shake-constant");
775 thonkings[a].children[
0].style.transform = 'rotate(
40deg) scale(
1,
1.5)'
776 thonkings[a].classList.add(shakes[Math.floor(Math.random()*shakes.length)]);
779 thonkings[a].style.right = randomnessX + 'px';
780 thonkings[a].style.bottom = randomnessY + 'px';
781 thonkings[a].classList.add(
"shake-constant");
782 thonkings[a].children[
0].style.transform = 'rotate(-
215deg) scale(
1,
1.5)'
783 thonkings[a].classList.add(shakes[Math.floor(Math.random()*shakes.length)]);
786 thonkings[a].style.left = randomnessX + 'px';
787 thonkings[a].style.bottom = randomnessY + 'px';
788 thonkings[a].classList.add(
"shake-constant");
789 thonkings[a].children[
0].style.transform = 'rotate(
215deg) scale(
1,
1.5)'
790 thonkings[a].classList.add(shakes[Math.floor(Math.random()*shakes.length)]);
795 usedPositions.push(thing);