-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
781 lines (735 loc) · 34.8 KB
/
Copy pathindex.html
File metadata and controls
781 lines (735 loc) · 34.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Play Framework Constructs</title>
<meta name="description" content="Func-tastic ways of Slicing and Dicing Play">
<meta name="author" content="Hiren Hiranandani">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/reveal.min.css">
<link rel="stylesheet" href="css/theme/night.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<style>
.left {
text-align:left;
}
.right {
text-align:left;
}
.logo_container {
background-color: #fff;
border: none;
border-radius: 30px;
padding: 50px;
}
</style>
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<section>
<p style="font-size: 40px;"><a href="https://github.com/bigH/play-func-presentation">https://github.com/bigH/play-func-presentation</a></p>
</section>
</section>
<section>
<section>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
object Ugly
this.code = Ugly
//can you see this??
</code></pre>
</section>
</section>
<section>
<section>
<h2 style="margin-bottom: 50px; color: #cfc;">Hiren Hiranandani</h2>
<h5>github: @bigH</h5>
<h5>twitter: @hhiranan</h5>
</section>
<section>
<img height="500" width="900" src="img/quake.gif">
</section>
<section>
<img height="500" width="900" src="img/happy.gif">
</section>
<section>
<img height="500" width="900" src="img/turbocpp.gif">
</section>
<section>
<img height="500" width="300" src="img/java.gif">
</section>
<section>
<img height="400" width="900" src="img/angry.gif">
</section>
<section>
<img height="500" width="700" src="img/haskell.png">
</section>
<section>
<img height="350" width="900" src="img/scala.gif">
</section>
<section>
<img height="350" width="900" src="img/powerful.gif">
</section>
<section>
<h2 style="margin-bottom: 50px;">"Scala Guy"</h2>
<ul>
<li>Do it in Scala!</li>
<li>Awesome Libraries</li>
<li>Awesome Frameworks</li>
</ul>
</section>
<section>
<img height="350" width="900" src="img/hifive.gif">
</section>
<section>
<div class="logo_container" style="margin-bottom: 50px;">
<img height="150" width="900" style="box-shadow: none; border: none;" src="img/bold-radius.png">
</div>
<ul>
<li>Typesafe Certified Training</li>
<li>Custom Scala Training</li>
<li>Code-Review</li>
<li>Mentoring</li>
<li>Development</li>
</ul>
</section>
<section>
<img height="500" width="900" src="img/nolookfistbump.gif">
</section>
</section>
<section>
<div class="left">
<h1 style="margin-bottom: 50px; color: #cfc;"><em>Play Framework<br/>Constructs:</em></h1>
<h3 style="margin-bottom: 50px;">Func-tastic ways of Slicing & Dicing Play</h3>
<h5 class="right">by <em style="color:#8f8">Hiren Hiranandani</em></h5>
</div>
</section>
<section>
<h2 style="margin-bottom: 50px;">Poll</h2>
</section>
<section>
<section>
<h2>What is Play Framework?</h2>
<h3>(read) Quick History Lesson</h3>
<h3>... emphasis on <span style="color: #8f8;">Quick</span></h3>
</section>
<section>
<h2 style="margin-bottom: 50px;">Web Frameworks</h2>
<ul>
<li>Rails</li>
<li>Django</li>
<li>Spring MVC</li>
</ul>
</section>
<section>
<img height="400" width="900" src="img/shrug.gif">
</section>
<section>
<h2 style="margin-bottom: 50px;">Then Came Scala</h2>
<h3>.. and Lift</h3>
<ul>
<li>Novel in Many Ways</li>
<li>Painful in Many Ways</li>
<li>Focus on Community was Lacking</li>
<li>Mini-Frameworking</li>
</ul>
</section>
<section>
<h2 style="margin-bottom: 50px;">Play Grows Up</h2>
<ul>
<li>Nice Mix of FP & OO</li>
<li>Plays Nice with other Technology</li>
<li>Blend of the Best
<ul>
<li>MVC Capable</li>
<li>Solid Templates</li>
<li>Great Type-Safety</li>
<li>Great JSON Support</li>
<li>Incremental Compilation</li>
<li>Async from the Bottom-Up</li>
</ul>
</li>
<li>Leveraging Scala the Right Way!</li>
</ul>
</section>
<section>
<img src="img/pbj.gif">
</section>
</section>
<section>
<section>
<h2>Quick Tour of Play</h2>
</section>
<section>
<h2 style="margin-bottom: 50px;">Get Started</h2>
<ul>
<li class="fragment">Download <a href="https://typesafe.com/activator">Activator</a></li>
<li class="fragment">Unzip and add to <code>PATH</code></li>
<li class="fragment">Run <code>activator new</code></li>
</ul>
</section>
<section>
<h2 style="margin-bottom: 50px;">Creating a New App</h2>
<img class="fragment" src="img/activator-new.gif">
</section>
<section>
<h2 style="margin-bottom: 50px;">App Complete!</h2>
<img height="400" width="900" src="img/shipeh.gif">
</section>
<section>
<h2 style="margin-bottom: 50px;">Live Coding</h2>
<!-- TODO: redo and break-down -->
<img class="fragment" src="img/activator-incremental-compile.gif">
</section>
<section>
<h2 style="margin-bottom: 50px;">Components</h2>
<h3 style="margin-bottom: 50px;">Routing</h3>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
GET /search/:term SearchController.search(term: String)
</code></pre>
</section>
<section>
<h2 style="margin-bottom: 50px;">Components</h2>
<h3 style="margin-bottom: 50px;">Controller</h3>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def search(term: String) = Action {
val results = performSearch(term)
Ok(views.search results results)
}
</code></pre>
<div class="fragment">
<h5 style="margin-bottom: 20px; margin-top: 30px;">... with Futures:</h5>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def search(term: String) = Action.async {
val results = Future { performSearch(term) }
results map (Ok(views.search results _))
}
</code></pre>
</div>
</section>
<section>
<h2 style="margin-bottom: 50px;">Components</h2>
<h3 style="margin-bottom: 50px;">Views</h3>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
@(results: List[SearchResult])
<p>Found @results.size results</p>
@if(!results.isEmpty) {
<ul>
@for(result <- results) {
<li>
<p><a href="@result.href">@result.title</a></p>
<p>@result.summary</p>
</li>
}
</ul>
}
</code></pre>
</section>
<section>
<h2 style="margin-bottom: 50px;">Out of the Box You Get...</h2>
<ul>
<li>Fully Configured Build</li>
<li>Fully Functioning Scala Project</li>
<li>Comes with Tests</li>
<li>Comes with Tools</li>
<li>IntelliJ: 'activator idea'</li>
<li>Eclipse: 'activator eclipse'</li>
</ul>
</section>
<section>
<h2 style="margin-bottom: 50px;">Play == Win</h2>
<img height="400" width="900" src="img/win.gif">
</section>
</section>
<section>
<section>
<h2 style="margin-bottom: 50px;">The M-word</h2>
<h3>Well Known Monads</h3>
</section>
<section>
<img src="img/monads.jpg">
</section>
<section>
<h2 style="margin-bottom: 50px;">Explaining Monads</h2>
<ul>
<li>Managing Computation</li>
<li>Well-Defined Semantics</li>
<li>Well-Defined Interface(s)</li>
</ul>
</section>
<section>
<h2 style="margin-bottom: 50px;">Well Known Monads</h2>
<h3><code>Option[T]</code></h3>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
val father = if (person == null) null else person.father
val mother = if (father == null) null else father.mother
val sister = if (mother == null) null else mother.sister
</code></pre>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
for {
father <- person.father
mother <- father.mother
sister <- mother.sister
} yield sister
</code></pre>
</section>
<section>
<h2 style="margin-bottom: 50px;">Well Known Monads</h2>
<h3><code>Try[T]</code></h3>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def tryReadInt(prompt: String) = Try(readLine(prompt)) map (_.toInt)
def divide: Try[Int] = {
val problem = for {
numerator <- tryReadInt("Enter Numerator:\n")
denominator <- tryReadInt("Enter Denominator:\n")
} yield (numerator / denominator)
problem orElse {
println("Y U NO Make Sense! Try again.")
divide
}
}
</code></pre>
</section>
<section>
<h2 style="margin-bottom: 50px;">Well Known Monads</h2>
<h3><code>Future[T]</code></h3>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def getUser(id: String): Future[User]
def getCart(user: User): Future[Cart]
def getFriends(user: User): Future[List[User]]
def getAffiliations(user: User): Future[List[Affiliation]]
</code></pre>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
for {
user <- getUser(id)
futureCart = getCart(user)
futureFriends = getFriends(user)
futureAffiliations = getAffiliations(user)
cart <- futureCart
friends <- futureFriends
affiliations <- futureAffiliations
} yield Response(...)
</code></pre>
</section>
<section>
<img height="500" width="800" src="img/daftfistbump.gif">
</section>
</section>
<section>
<section>
<h2 style="margin-bottom: 50px;">The Functions You See</h2>
<h3>Controllers == Functions</h3>
</section>
<section>
<h2 style="margin-bottom: 50px;">By Default...</h2>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def search(term: String) = Action {
val results = performSearch(term)
Ok(views.search.results(results))
}
</code></pre>
</section>
<section>
<h2 style="margin-bottom: 50px;">Composition</h2>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
trait FunctionalController {
def builder: ActionBuilder
def failureView(ex: Throwable): Html
def action[A](logic: => A,
renderer: A => Html,
failure: Throwable => Html = failureView) = builder {
Try(logic) map renderer match {
case Success(view) => Ok(view)
case Failure(ex) => Error(failure(ex))
}
}
}
</code></pre>
</section>
<section>
<h2 style="margin-bottom: 50px;">Composition</h2>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
class SearchController extends FunctionalController {
def Builder = MySpecialAction
def failureView = views.search.failed
def search(term: String) = action (
logic = performSearch(term),
renderer = views.search.results
)
}
</code></pre>
</section>
<section>
<h2 style="margin-bottom: 50px;">The Functions You See</h2>
<h3>Views == Functions</h3>
</section>
<section>
<h2 style="margin-bottom: 50px;">Layouts</h2>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
trait FunctionalController {
def layout: Html => Html
def action[A](logic: => A,
renderer: A => Html,
failure: ...) = builder {
Try(logic) map (renderer andThen layout) match {
case Success(view) => Ok(view)
case Failure(ex) => Error(failure(ex))
}
}
}
</code></pre>
</section>
<section>
<h2 style="margin-bottom: 50px;">Bigger Layouts</h2>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
type Layout = Html => Html
def composeLayout(views: Map[String, Future[Html]],
layout: Map[String, Html] => Layout): Future[Layout] = {
val listOfFutureTuples = views map {
case (name, fHtml) => fHtml map ((name, _))
}
Future sequence listOfFutureTuples map (_.toMap) map layout
}
</code></pre>
</section>
<section>
<h2 style="margin-bottom: 50px;">Bigger Layouts</h2>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
type Layout = Html => Html
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def widgets: Map[String, Future[Html]]
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def layout(view: A => Html): Future[A => Html] = {
for {
layout <- composeLayout(widgets, views.layouts.default)
} yield {
(a: A) => layout(view(a))
}
}
</code></pre>
<p class="fragment">Assuming <code>action</code> supports <code>Future</code></p>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def search(term: String) = action (
logic = performSearch(term),
renderer = layout(views.search.results)
)
</code></pre>
</section>
<section>
<img height="500" width="500" src="img/happydance.gif">
</section>
</section>
<section>
<section>
<h2 style="margin-bottom: 50px;">Service as a Function</h2>
<h3 style="margin-bottom: 50px;">REST with Functional Style</h3>
<h5>Credit goes to @marius</h5>
</section>
<section>
<h2 style="margin-bottom: 50px;">Some Definitions</h2>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
type Service[In, Out] = (In => Future[Out])
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
type Map[A, B, In, Out] =
(A, Service[In, Out]) => Future[B]
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
type Filter[In, Out] = Map[In, Out, In, Out]
</code></pre>
</section>
<section>
<h2 style="margin-bottom: 50px;">Mental Model</h2>
<img src="img/service.png">
</section>
<section>
<h2 style="margin-bottom: 50px;">Composition</h2>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
type Map[A, B, In, Out] =
(A, Service[In, Out]) => Future[B]
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
val map: Map[A, B, In, Out] = _
val inner: Service[In, Out] = _
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
val outer: Service[A, B] = map(_, inner)
</code></pre>
</section>
<section>
<h2 style="margin-bottom: 50px;">Usage: Timer</h2>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
type Filter[In, Out] = (In, Service[In, Out]) => Future[Out]
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
class Timer[A, B](name: String) extends Filter[A, B] {
def now = System.currentTimeMillis
def apply(a: A, service: Service[A, B]): Future[B] = {
val start = now
val result = service(a)
result foreach {
_ => recordTime(name, now - start)
}
result
}
}
</code></pre>
</section>
<section>
<h2 style="margin-bottom: 50px;">Usage: AwesomeFilter</h2>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
type Filter[In, Out] = (In, Service[In, Out]) => Future[Out]
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
val filter: Filter[In, Out] = _
val inner: Service[In, Out] = _
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
val outer: Service[In, Out] = filter(_, inner)
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
class AwesomeFilter[A, B](name: String,
defaults: List[Filter[A, B]])
extends Filter[A, B] {
var filters = defaults
def addFilter(filter: Filter[A, B]) { ... }
def apply(a: A, service: Service[A, B]): Future[B] = {
filters.foldRight(service)((filter, acc) => filter(_, acc))
}
}
</code></pre>
</section>
<section>
<img height="500" width="700" src="img/carlton.gif">
</section>
</section>
<section>
<section>
<h2 style="margin-bottom: 50px;">Application as a Function</h2>
<h3>Seeing Everything as a Function</h3>
</section>
<section>
<h2 style="margin-bottom: 50px;">The Premise</h2>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
service: Service[Request, Response]
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
application: Configuration => Service[Request, Response]
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
class Dependencies(configuration: Configuration) {
val db = DB(configuration)
val system = System(configuration)
}
</code></pre>
</section>
<section>
<h2 style="margin-bottom: 50px;">How It's Done</h2>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def configuration = Configuration.current
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def serviceBuilder: Dependencies => Service[Request, Response]
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def applicationBuilder = Dependencies.apply andThen serviceBuilder
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def service = applicationBuilder(configuration)
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def action = ActionBuilder { service }
</code></pre>
</section>
<section>
<img height="500" width="600" src="img/stewart-win.gif">
</section>
</section>
<section>
<section>
<h2 style="margin-bottom: 50px;">The M-word continues...</h2>
<h3>Monads for Better Play</h3>
</section>
<section>
<h2 style="margin-bottom: 50px;">The Reader Monad</h2>
<ul>
<li>Analogous to Functions<br/>
<code>Reader[A, B] ~ A => B</code>
</li>
<li>Common <em>Context</em> or <em>Environment</em></li>
<li>Richer than functions</li>
</ul>
</section>
<section>
<h2 style="margin-bottom: 50px;">The Reader Monad</h2>
<h3>Definitions</h3>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
trait Reader[Env, A] {
def apply(env: Env): A
def map(f: A => B): Reader[Env, B]
def flatMap(f: A => Reader[Env, B]): Reader[Env, B]
def zipWith(f: (A, B) => C)
(b: Reader[Env, B]): Reader[Env, C]
// ...
}
</code></pre>
</section>
<section>
<h2 style="margin-bottom: 50px;">The Reader Monad</h2>
<h3>Let's Rewrite <code>application</code></h3>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def configuration = Configuration.current
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def serviceBuilder: Dependencies => Service[Request, Response]
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def applicationBuilder = Reader(Dependencies.apply) map serviceBuilder
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def service = applicationBuilder(configuration)
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def action = ActionBuilder { service }
</code></pre>
</section>
<section>
<h2 style="margin-bottom: 50px;">The Reader Monad</h2>
<h3 style="margin-bottom: 50px;">Remember ...</h3>
<h5>Decomposing Logic & Presentation</h5>
<pre><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def servicer[A]: Dependencies => Service[Request, A]
def presenter[A]: Dependencies => Service[A, Response]
</code></pre>
<p class="fragment">A bit of <code>Future</code>/<code>Service</code> glue</p>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def serviceChainer[A, B, C](first: Service[A, B], second: Service[B, C]) =
(a: A) => first(a) flatMap second
</code></pre>
<pre class="fragment"><code data-trim contenteditable style="font-size: 18px; margin-top: 20px;">
def serviceBuilder = Reader(servicer).zipWith(serviceChainer)(Reader(presenter))
</code></pre>
<p class="fragment">Thank <code>Reader</code>.</p>
</section>
<section>
<h2 style="margin-bottom: 50px;">So What?</h2>
<h5 style="margin-bottom: 50px;">Reader is ...</h5>
<ul>
<li>Really Simple</li>
<li>Easy to Build</li>
<li>Good First "Hard" Monad</li>
<li>Adapts to Your View</li>
</ul>
</section>
<section>
<img height="350" width="800" src="img/travolta-win.gif">
</section>
</section>
<section>
<section>
<h2 style="margin-bottom: 50px;">Useful Tools</h2>
<h3>Reducing Boilerplate</h3>
</section>
<section>
<h2 style="margin-bottom: 50px;">Remember...</h2>
<ul>
<li><code>sbt</code> build is a Scala program</li>
<li><code>sbt-boilerplate</code> - an <code>sbt</code> plugin</li>
<li>writing an embedded DSL in Scala is easy (see other talks)</li>
<li>writing a language in Scala is easy (parser-combinators)</li>
<li>that we also have macros</li>
</ul>
</section>
<section>
<img height="500" width="700" src="img/willsmithdance.gif">
</section>
</section>
<section>
<section>
<h2 style="margin-bottom: 50px;">Simplify</h2>
<ul>
<li class="fragment">Small</li>
<li class="fragment">Understandable</li>
<li class="fragment">Cognitive Load</li>
</ul>
</section>
<section>
<h2 style="margin-bottom: 50px;">Isolate</h2>
<ul>
<li class="fragment">Cross Cutting Concerns</li>
<li class="fragment">Exactly <strong>One</strong> Thing</li>
</ul>
</section>
<section>
<h2 style="margin-bottom: 50px;">Compose</h2>
<ul>
<li class="fragment">The Legos Way</li>
<li class="fragment">Cut Along Dimensions</li>
<li class="fragment">Build a Mental Model</li>
</ul>
</section>
</section>
<section>
<section>
<img height="500" width="800" src="img/end.gif">
</section>
<section>
<img src="img/qna.gif">
</section>
</section>
<section>
<section>
<p style="font-size: 40px;"><a href="https://github.com/bigH/play-func-presentation">https://github.com/bigH/play-func-presentation</a></p>
</section>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
slideNumber: true,
history: true,
center: true,
previewLinks: true,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none
// Parallax scrolling
// parallaxBackgroundImage: 'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg',
// parallaxBackgroundSize: '2100px 900px',
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>