-
Notifications
You must be signed in to change notification settings - Fork 6
/
defence-slides.html
1182 lines (938 loc) · 71.6 KB
/
defence-slides.html
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
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>The Next 700 Module Systems</title>
<meta name="author" content="((link (:type https :path //alhassy.github.io/next-700-module-systems-proposal :format bracket :raw-link https://alhassy.github.io/next-700-module-systems-proposal :application nil :search-option nil :begin 1 :end 78 :contents-begin 63 :contents-end 76 :post-blank 0 :parent #0) Musa Al-hassy))"/>
<meta name="description" content="Thesis proposal for Musa Al-hassy; McMaster University 2019."/>
<style type="text/css">
.underline { text-decoration: underline; }
</style>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/reveal.js/3.0.0/css/reveal.css"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/reveal.js/3.0.0/css/theme/sky.css" id="theme"/>
<link rel="stylesheet" href="./local.css"/>
<!-- 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 = 'https://cdn.jsdelivr.net/reveal.js/3.0.0/css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section id="sec-title-slide"><h1 class="title">The Next 700 Module Systems</h1><h2 class="author"><a href="https://alhassy.github.io/next-700-module-systems-proposal">Musa Al-hassy</a></h2>
</section>
<style>
.reveal .slide-number {
font-size: 34pt;
color: #ff2D00; }
.reveal .slides {
height: 100%;
width: 100% !important ;
top: 0;
margin-top: 0;
}
.reveal .slides>section {
min-height: 90%;
min-width: 90%;
}
.reveal .slides>section>section {
min-height: 100%;
}
.print-pdf .reveal .slides > section.present, .print-pdf .reveal .slides > section > section.present {
min-height: 770px !important;
position: relative !important;
}
.reveal table th, .reveal table td {
text-align: left;
border: none;
border-left: 1px solid transparent;
border-right: 1px solid transparent;
}
.reveal ul {
line-height: 200%
}
.reveal ol {
line-height: 200%
}
.reveal dl {
line-height: 200%
}
.reveal p {
line-height: 200%
}
.reveal pre {
font-size: 1em;
box-shadow:none;
}
</style>
<section>
<section id="slide-orga268668">
<h2 id="orga268668">Overview</h2>
<ul>
<li>Introduction —The Proposal's Story
<ol>
<li>A Programming Language Has Many Tongues</li>
<li>Exploring Grouping Mechanisms</li>
<li>Problem Statement</li>
</ol></li>
<li>Solution Requirements
<ol>
<li>Desirable Features</li>
<li>Related Works</li>
<li>Visualisation of Parts of the Proposed “Package Polymorphism”</li>
</ol></li>
<li>Approach</li>
<li>Timeline</li>
<li>Conclusion</li>
</ul>
<aside class="notes">
<p>
<b>Goal</b> :: Provide primitives that minimise repetition
for manipulating grouping mechanisms,
without the end-user utilising any preprocessing.
</p>
</aside>
</section>
</section>
<section>
<section id="slide-orga80d996">
<h2 id="orga80d996">A Programming Language Has Many Tongues</h2>
<ol>
<li class="fragment appear">Expression</li>
<li class="fragment appear">Statement</li>
<li class="fragment appear">Type</li>
<li class="fragment appear">Specification</li>
<li class="fragment appear">Proof</li>
<li class="fragment appear">Module</li>
<li class="fragment appear">Meta-programming</li>
</ol>
<p class="fragment">
The first five collapse into one uniform language
within the dependently-typed language Agda.
</p>
<p class="fragment">
<b>So why not the module language?</b>
</p>
<aside class="notes">
<ul>
<li>Let's set the stage for what's coming up.</li>
<li>Can modules be treated the same way as the others?</li>
<li>First question then is what is a module?</li>
</ul>
</aside>
</section>
</section>
<section>
<section id="slide-org1f9b35e">
<h2 id="org1f9b35e">What is a Module?</h2>
<p class="fragment (appear)">
<b>Definition:</b> A typed <i>module, context, telescope, package former, record, typeclass</i>
is a sequence of tuples:
</p>
<center><table width="50%" border="0""><tr><td>
<div class="org-src-container">
<pre class="fragment appear"> <span style="color: #228b22;">Name</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Type</span> <span style="color: #228b22;">:=</span> <span style="color: #228b22;">Optional_Definition</span>
</pre>
</div>
</td><tr></table></center>
<p class="fragment appear">
Without types, we obtain essentially JSON Objects.
</p>
<p class="fragment (appear)">
<b>Purpose:</b> Group related concepts together as single <i>semantic</i> units.
</p>
</section>
</section>
<section>
<section id="slide-orgf43c844">
<h2 id="orgf43c844">Expectations of Module Systems</h2>
<dl>
<dt class="fragment appear">Namespacing</dt><dd class="fragment appear">New unique local scopes ⇒ de-coupling</dd>
<dt class="fragment appear">Information Hiding</dt><dd class="fragment appear">Inaccessibility ⇒ Implementation independence</dd>
<dt class="fragment appear">Citizenship</dt><dd class="fragment appear">Grouping mechanisms should be treated like ordinary values</dd>
<dt class="fragment appear">Polymorphism</dt><dd class="fragment appear">Grouping mechanisms should group all kinds of things without prejudice</dd>
<dt class="fragment appear">Object-Orientation</dt><dd class="fragment appear">Generative modules & Subtyping</dd>
</dl>
</section>
</section>
<section>
<section id="slide-orgc8cabab">
<h2 id="orgc8cabab">What about ⋯</h2>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides" class="fragment (appear)">
<colgroup>
<col class="org-left" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-left"> </td>
<td class="org-left">Packages</td>
</tr>
<tr>
<td class="org-left">≈?</td>
<td class="org-left">modules</td>
</tr>
<tr>
<td class="org-left">≈?</td>
<td class="org-left">theories</td>
</tr>
<tr>
<td class="org-left">≈?</td>
<td class="org-left">contexts</td>
</tr>
<tr>
<td class="org-left">≈?</td>
<td class="org-left">typeclasses</td>
</tr>
<tr>
<td class="org-left">≈?</td>
<td class="org-left">⋯</td>
</tr>
<tr>
<td class="org-left">≈?</td>
<td class="org-left">dependent records</td>
</tr>
</tbody>
</table>
<blockquote class="fragment">
<p>
Differences ≈?⇒ Uses & Implementations
</p>
</blockquote>
</section>
</section>
<section>
<section id="slide-orgc167e4a">
<h2 id="orgc167e4a">Facets of Structuring Mechanisms: An Agda Rendition</h2>
<p>
Different ways one would encode monoid definitions in their
code for different purposes
</p>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-left">⇒</td>
<td class="org-left">Monoids with a dynamically known carrier</td>
</tr>
<tr>
<td class="org-left">⇒</td>
<td class="org-left">Monoids with a statically known carrier</td>
</tr>
<tr>
<td class="org-left">⇒</td>
<td class="org-left">Monoids as raw tuples</td>
</tr>
<tr>
<td class="org-left">⇒</td>
<td class="org-left">Monoids as telescopes</td>
</tr>
<tr>
<td class="org-left">⇄</td>
<td class="org-left">Derived operations</td>
</tr>
</tbody>
</table>
<aside class="notes">
<p>
Give idea of what's coming up, so we have a mental strucutre of
where to put things, what holes fill what expectations.
</p>
</aside>
</section>
</section>
<section>
<section id="slide-orgbece806">
<h3 id="orgbece806">Monoids as Agda Records</h3>
<div style="font-size: 95%;">
<center><table width="50%" border="0""><tr><td>
<div class="org-src-container">
<pre class="src src-haskell"><span style="color: #0000ff;">record</span> <span style="color: #228b22;">Monoid</span><span style="color: #a0522d;">-</span><span style="color: #228b22;">Record</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span>₁ <span style="color: #a020f0;">where</span>
<span style="color: #a020f0;">infixl</span> 5 <span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span><span style="color: #a020f0;">_</span>
field
<span style="color: #b22222;">-- </span><span style="color: #b22222;">Interface</span>
<span style="color: #228b22;">Carrier</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span>
<span style="color: #228b22;">Id</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Carrier</span>
<span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span><span style="color: #a020f0;">_</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Carrier</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Carrier</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Carrier</span>
<span style="color: #b22222;">-- </span><span style="color: #b22222;">Constraints</span>
lid <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span><span style="color: #707183;">{</span>x<span style="color: #707183;">}</span> <span style="color: #a0522d;">→</span> <span style="color: #707183;">(</span><span style="color: #228b22;">Id</span> <span style="color: #a0522d;">⨾</span> x<span style="color: #707183;">)</span> <span style="color: #a0522d;">≡</span> x
rid <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span><span style="color: #707183;">{</span>x<span style="color: #707183;">}</span> <span style="color: #a0522d;">→</span> <span style="color: #707183;">(</span>x <span style="color: #a0522d;">⨾</span> <span style="color: #228b22;">Id</span><span style="color: #707183;">)</span> <span style="color: #a0522d;">≡</span> x
assoc <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span> x y z <span style="color: #a0522d;">→</span> <span style="color: #707183;">(</span>x <span style="color: #a0522d;">⨾</span> y<span style="color: #707183;">)</span> <span style="color: #a0522d;">⨾</span> z <span style="color: #a0522d;">≡</span> x <span style="color: #a0522d;">⨾</span> <span style="color: #707183;">(</span>y <span style="color: #a0522d;">⨾</span> z<span style="color: #707183;">)</span>
<span style="color: #b22222;">-- </span><span style="color: #b22222;">derived result</span>
pop<span style="color: #a0522d;">-</span><span style="color: #228b22;">Idᵣ</span> <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span> x y <span style="color: #a0522d;">→</span> x <span style="color: #a0522d;">⨾</span> <span style="color: #228b22;">Id</span> <span style="color: #a0522d;">⨾</span> y <span style="color: #a0522d;">≡</span> x <span style="color: #a0522d;">⨾</span> y
pop<span style="color: #a0522d;">-</span><span style="color: #228b22;">Idᵣ</span> x y <span style="color: #a0522d;">=</span> cong <span style="color: #707183;">(</span><span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span> y<span style="color: #707183;">)</span> rid
</pre>
</div>
<p>
⇨ Carrier sets, functions, and axioms <i>all</i> are record fields.
</p>
</td><tr></table></center>
</div>
</section>
</section>
<section>
<section id="slide-orgc0c775c">
<h3 id="orgc0c775c">Monoids as Typeclasses</h3>
<div style="font-size: 95%;">
<center><table width="50%" border="0""><tr><td>
<div class="org-src-container">
<pre class="src src-haskell"><span style="color: #0000ff;">record</span> <span style="color: #228b22;">HasMonoid</span> <span style="color: #707183;">(</span><span style="color: #228b22;">Carrier</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span><span style="color: #707183;">)</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span>₁ <span style="color: #a020f0;">where</span>
<span style="color: #a020f0;">infixl</span> 5 <span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span><span style="color: #a020f0;">_</span>
field
<span style="color: #228b22;">Id</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Carrier</span>
<span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span><span style="color: #a020f0;">_</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Carrier</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Carrier</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Carrier</span>
lid <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span><span style="color: #707183;">{</span>x<span style="color: #707183;">}</span> <span style="color: #a0522d;">→</span> <span style="color: #707183;">(</span><span style="color: #228b22;">Id</span> <span style="color: #a0522d;">⨾</span> x<span style="color: #707183;">)</span> <span style="color: #a0522d;">≡</span> x
rid <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span><span style="color: #707183;">{</span>x<span style="color: #707183;">}</span> <span style="color: #a0522d;">→</span> <span style="color: #707183;">(</span>x <span style="color: #a0522d;">⨾</span> <span style="color: #228b22;">Id</span><span style="color: #707183;">)</span> <span style="color: #a0522d;">≡</span> x
assoc <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span> x y z <span style="color: #a0522d;">→</span> <span style="color: #707183;">(</span>x <span style="color: #a0522d;">⨾</span> y<span style="color: #707183;">)</span> <span style="color: #a0522d;">⨾</span> z <span style="color: #a0522d;">≡</span> x <span style="color: #a0522d;">⨾</span> <span style="color: #707183;">(</span>y <span style="color: #a0522d;">⨾</span> z<span style="color: #707183;">)</span>
pop<span style="color: #a0522d;">-</span><span style="color: #228b22;">Id</span><span style="color: #a0522d;">-</span>tc <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span> x y <span style="color: #a0522d;">→</span> x <span style="color: #a0522d;">⨾</span> <span style="color: #228b22;">Id</span> <span style="color: #a0522d;">⨾</span> y <span style="color: #a0522d;">≡</span> x <span style="color: #a0522d;">⨾</span> y
pop<span style="color: #a0522d;">-</span><span style="color: #228b22;">Id</span><span style="color: #a0522d;">-</span>tc x y <span style="color: #a0522d;">=</span> cong <span style="color: #707183;">(</span><span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span> y<span style="color: #707183;">)</span> rid
<span style="color: #b22222;">{- </span><span style="color: #b22222;">We make this record type available</span>
<span style="color: #b22222;"> to instance search, “typeclass”. -}</span>
<span style="color: #0000ff;">open</span> <span style="color: #228b22;">HasMonoid</span> <span style="color: #707183;">{</span><span style="color: #7388d6;">{</span><span style="color: #a0522d;">...</span><span style="color: #7388d6;">}</span><span style="color: #707183;">}</span> using <span style="color: #707183;">(</span>pop<span style="color: #a0522d;">-</span><span style="color: #228b22;">Id</span><span style="color: #a0522d;">-</span>tc<span style="color: #707183;">)</span>
</pre>
</div>
<p>
⇨ Only functions and axioms are record fields —the carrier set is a <i>parameter</i>.
</p>
</td><tr></table></center>
</div>
</section>
</section>
<section>
<section id="slide-orge3c0384">
<h3 id="orge3c0384">These are the ‘Same’</h3>
<div style="font-size: 70%;">
<div style="width:50%;float:left">
<p>
⇨ Monoids as Agda Records
</p>
<div class="org-src-container">
<pre class="src src-haskell"><span style="color: #0000ff;">record</span> <span style="color: #228b22;">Monoid</span><span style="color: #a0522d;">-</span><span style="color: #228b22;">Record</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span>₁ <span style="color: #a020f0;">where</span>
field
<span style="color: #b22222;">-- </span><span style="color: #b22222;">Interface</span>
<span style="color: #228b22;">Carrier</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span>
<span style="color: #228b22;">Id</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Carrier</span>
<span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span><span style="color: #a020f0;">_</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Carrier</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Carrier</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Carrier</span>
<span style="color: #b22222;">-- </span><span style="color: #b22222;">Constraints</span>
lid <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span><span style="color: #707183;">{</span>x<span style="color: #707183;">}</span> <span style="color: #a0522d;">→</span> <span style="color: #707183;">(</span><span style="color: #228b22;">Id</span> <span style="color: #a0522d;">⨾</span> x<span style="color: #707183;">)</span> <span style="color: #a0522d;">≡</span> x
rid <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span><span style="color: #707183;">{</span>x<span style="color: #707183;">}</span> <span style="color: #a0522d;">→</span> <span style="color: #707183;">(</span>x <span style="color: #a0522d;">⨾</span> <span style="color: #228b22;">Id</span><span style="color: #707183;">)</span> <span style="color: #a0522d;">≡</span> x
assoc <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span> x y z <span style="color: #a0522d;">→</span> <span style="color: #707183;">(</span>x <span style="color: #a0522d;">⨾</span> y<span style="color: #707183;">)</span> <span style="color: #a0522d;">⨾</span> z <span style="color: #a0522d;">≡</span> x <span style="color: #a0522d;">⨾</span> <span style="color: #707183;">(</span>y <span style="color: #a0522d;">⨾</span> z<span style="color: #707183;">)</span>
<span style="color: #b22222;">-- </span><span style="color: #b22222;">derived result</span>
pop<span style="color: #a0522d;">-</span><span style="color: #228b22;">Idᵣ</span> <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span> x y <span style="color: #a0522d;">→</span> x <span style="color: #a0522d;">⨾</span> <span style="color: #228b22;">Id</span> <span style="color: #a0522d;">⨾</span> y <span style="color: #a0522d;">≡</span> x <span style="color: #a0522d;">⨾</span> y
pop<span style="color: #a0522d;">-</span><span style="color: #228b22;">Idᵣ</span> x y <span style="color: #a0522d;">=</span> cong <span style="color: #707183;">(</span><span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span> y<span style="color: #707183;">)</span> rid
<span style="color: #b22222;">{- </span><span style="color: #b22222;">Monoid-Record ≅ Σ C ∶ Set • HasMonoid C -}</span>
</pre>
</div>
</div> <div style="width:50%;float: left">
<p>
⇨ Monoids as Typeclasses
</p>
<div class="org-src-container">
<pre class="src src-haskell"><span style="color: #0000ff;">record</span> <span style="color: #228b22;">HasMonoid</span> <span style="color: #707183;">(</span><span style="color: #228b22;">Carrier</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span><span style="color: #707183;">)</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span>₁ <span style="color: #a020f0;">where</span>
field
<span style="color: #b22222;">-- </span><span style="color: #b22222;">Interface</span>
<span style="color: #b22222;">{- </span><span style="color: #b22222;">Notice that “Carrier” is a parameter. -}</span>
<span style="color: #228b22;">Id</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Carrier</span>
<span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span><span style="color: #a020f0;">_</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Carrier</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Carrier</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Carrier</span>
<span style="color: #b22222;">-- </span><span style="color: #b22222;">Constraints</span>
lid <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span><span style="color: #707183;">{</span>x<span style="color: #707183;">}</span> <span style="color: #a0522d;">→</span> <span style="color: #707183;">(</span><span style="color: #228b22;">Id</span> <span style="color: #a0522d;">⨾</span> x<span style="color: #707183;">)</span> <span style="color: #a0522d;">≡</span> x
rid <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span><span style="color: #707183;">{</span>x<span style="color: #707183;">}</span> <span style="color: #a0522d;">→</span> <span style="color: #707183;">(</span>x <span style="color: #a0522d;">⨾</span> <span style="color: #228b22;">Id</span><span style="color: #707183;">)</span> <span style="color: #a0522d;">≡</span> x
assoc <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span> x y z <span style="color: #a0522d;">→</span> <span style="color: #707183;">(</span>x <span style="color: #a0522d;">⨾</span> y<span style="color: #707183;">)</span> <span style="color: #a0522d;">⨾</span> z <span style="color: #a0522d;">≡</span> x <span style="color: #a0522d;">⨾</span> <span style="color: #707183;">(</span>y <span style="color: #a0522d;">⨾</span> z<span style="color: #707183;">)</span>
<span style="color: #b22222;">-- </span><span style="color: #b22222;">derived result</span>
pop<span style="color: #a0522d;">-</span><span style="color: #228b22;">Id</span><span style="color: #a0522d;">-</span>tc <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span> x y <span style="color: #a0522d;">→</span> x <span style="color: #a0522d;">⨾</span> <span style="color: #228b22;">Id</span> <span style="color: #a0522d;">⨾</span> y <span style="color: #a0522d;">≡</span> x <span style="color: #a0522d;">⨾</span> y
pop<span style="color: #a0522d;">-</span><span style="color: #228b22;">Id</span><span style="color: #a0522d;">-</span>tc x y <span style="color: #a0522d;">=</span> cong <span style="color: #707183;">(</span><span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span> y<span style="color: #707183;">)</span> rid
<span style="color: #b22222;">{- </span><span style="color: #b22222;">HasMonoid ≅ λ C → Σ M ∶ Monoid-Record • M.Carrier ≡ C -}</span>
</pre>
</div>
</div>
</div>
</section>
</section>
<section>
<section id="slide-orga4e92cf">
<h3 id="orga4e92cf">Monoids as Direct Dependent Sums</h3>
<div style="width:50%;float:left">
<div class="org-src-container">
<pre class="src src-haskell"><span style="color: #228b22;">Monoid</span><span style="color: #0000ff;">-</span><span style="color: #228b22;">Σ</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span>₁
<span style="color: #228b22;">Monoid</span><span style="color: #0000ff;">-</span><span style="color: #228b22;">Σ</span> <span style="color: #a0522d;">=</span> <span style="color: #228b22;">Σ</span> <span style="color: #228b22;">Carrier</span> <span style="color: #a0522d;">∶</span> <span style="color: #228b22;">Set</span>
<span style="color: #a0522d;">•</span> <span style="color: #228b22;">Σ</span> <span style="color: #228b22;">Id</span> <span style="color: #a0522d;">∶</span> <span style="color: #228b22;">Carrier</span>
<span style="color: #a0522d;">•</span> <span style="color: #228b22;">Σ</span> <span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span><span style="color: #a020f0;">_</span> <span style="color: #a0522d;">∶</span> <span style="color: #707183;">(</span><span style="color: #228b22;">Carrier</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Carrier</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Carrier</span><span style="color: #707183;">)</span>
<span style="color: #a0522d;">•</span> <span style="color: #228b22;">Σ</span> lid <span style="color: #a0522d;">∶</span> <span style="color: #707183;">(</span><span style="color: #a0522d;">∀</span><span style="color: #7388d6;">{</span>x<span style="color: #7388d6;">}</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Id</span> <span style="color: #a0522d;">⨾</span> x <span style="color: #a0522d;">≡</span> x<span style="color: #707183;">)</span>
<span style="color: #a0522d;">•</span> <span style="color: #228b22;">Σ</span> rid <span style="color: #a0522d;">∶</span> <span style="color: #707183;">(</span><span style="color: #a0522d;">∀</span><span style="color: #7388d6;">{</span>x<span style="color: #7388d6;">}</span> <span style="color: #a0522d;">→</span> x <span style="color: #a0522d;">⨾</span> <span style="color: #228b22;">Id</span> <span style="color: #a0522d;">≡</span> x<span style="color: #707183;">)</span>
<span style="color: #a0522d;">•</span> <span style="color: #707183;">(</span><span style="color: #a0522d;">∀</span> x y z <span style="color: #a0522d;">→</span> <span style="color: #7388d6;">(</span>x <span style="color: #a0522d;">⨾</span> y<span style="color: #7388d6;">)</span> <span style="color: #a0522d;">⨾</span> z <span style="color: #a0522d;">≡</span> x <span style="color: #a0522d;">⨾</span> <span style="color: #7388d6;">(</span>y <span style="color: #a0522d;">⨾</span> z<span style="color: #7388d6;">)</span><span style="color: #707183;">)</span>
pop<span style="color: #0000ff;">-</span><span style="color: #228b22;">Id</span><span style="color: #a0522d;">-</span><span style="color: #228b22;">Σ</span> <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span><span style="color: #707183;">{</span><span style="color: #7388d6;">{</span><span style="color: #228b22;">M</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Monoid</span><span style="color: #a0522d;">-</span><span style="color: #228b22;">Σ</span><span style="color: #7388d6;">}</span><span style="color: #707183;">}</span>
<span style="color: #707183;">(</span><span style="color: #a020f0;">let</span> <span style="color: #228b22;">Id</span> <span style="color: #a0522d;">=</span> proj₁ <span style="color: #7388d6;">(</span>proj₂ <span style="color: #228b22;">M</span><span style="color: #7388d6;">)</span><span style="color: #707183;">)</span>
<span style="color: #707183;">(</span><span style="color: #a020f0;">let</span> <span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span><span style="color: #a020f0;">_</span> <span style="color: #a0522d;">=</span> proj₁ <span style="color: #7388d6;">(</span>proj₂ <span style="color: #909183;">(</span>proj₂ <span style="color: #228b22;">M</span><span style="color: #909183;">)</span><span style="color: #7388d6;">)</span><span style="color: #707183;">)</span>
<span style="color: #a0522d;">→</span> <span style="color: #a0522d;">∀</span> <span style="color: #707183;">(</span>x y <span style="color: #228b22;">:</span> proj₁ <span style="color: #228b22;">M</span><span style="color: #707183;">)</span> <span style="color: #a0522d;">→</span> <span style="color: #707183;">(</span>x <span style="color: #a0522d;">⨾</span> <span style="color: #228b22;">Id</span><span style="color: #707183;">)</span> <span style="color: #a0522d;">⨾</span> y <span style="color: #a0522d;">≡</span> x <span style="color: #a0522d;">⨾</span> y
pop<span style="color: #0000ff;">-</span><span style="color: #228b22;">Id</span><span style="color: #a0522d;">-</span><span style="color: #228b22;">Σ</span> <span style="color: #707183;">{</span><span style="color: #7388d6;">{</span><span style="color: #228b22;">M</span><span style="color: #7388d6;">}</span><span style="color: #707183;">}</span> x y <span style="color: #a0522d;">=</span> cong <span style="color: #707183;">(</span><span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span> y<span style="color: #707183;">)</span> <span style="color: #707183;">(</span>rid <span style="color: #7388d6;">{</span>x<span style="color: #7388d6;">}</span><span style="color: #707183;">)</span>
<span style="color: #a020f0;">where</span> <span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span><span style="color: #a020f0;">_</span> <span style="color: #a0522d;">=</span> proj₁ <span style="color: #707183;">(</span>proj₂ <span style="color: #7388d6;">(</span>proj₂ <span style="color: #228b22;">M</span><span style="color: #7388d6;">)</span><span style="color: #707183;">)</span>
rid <span style="color: #a0522d;">=</span> proj₁ <span style="color: #707183;">(</span>proj₂ <span style="color: #7388d6;">(</span>proj₂ <span style="color: #909183;">(</span>proj₂ <span style="color: #709870;">(</span>proj₂ <span style="color: #228b22;">M</span><span style="color: #709870;">)</span><span style="color: #909183;">)</span><span style="color: #7388d6;">)</span><span style="color: #707183;">)</span>
</pre>
</div>
</div> <div style="width:50%;float: left">
<p class="fragment (appear)">
⇨ The navigational feature of record fields is <i>replaced</i> by projections
—i.e., it's just a different encoding.
</p>
<div style="font-size: 80%;">
<div class="org-src-container">
<pre class="fragment (appear)"> <span style="color: #b22222;">{- </span><span style="color: #b22222;">Boilerplate -}</span>
<span style="color: #228b22;">Carrier</span><span style="color: #a0522d;">′</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Monoid</span><span style="color: #a0522d;">-</span><span style="color: #228b22;">Σ</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Set</span>
<span style="color: #228b22;">Carrier</span><span style="color: #a0522d;">′</span> <span style="color: #a0522d;">=</span> proj₁
</pre>
</div>
</div>
</div>
</section>
</section>
<section>
<section id="slide-orga64e2ef">
<h3 id="orga64e2ef">A Missing Polymorphism</h3>
<div style="font-size: 90%;">
<div style="width:50%;float:left">
<div class="org-src-container">
<pre class="src src-haskell"><span style="color: #228b22;">ℕ</span><span style="color: #a0522d;">-</span>record <span style="color: #228b22;">:</span> <span style="color: #228b22;">Monoid</span><span style="color: #a0522d;">-</span><span style="color: #228b22;">Record</span>
<span style="color: #228b22;">ℕ</span><span style="color: #a0522d;">-</span>record <span style="color: #a0522d;">=</span> record <span style="color: #707183;">{</span> <span style="color: #228b22;">Carrier</span> <span style="color: #a0522d;">=</span> <span style="color: #228b22;">ℕ</span>; <span style="color: #228b22;">Id</span> <span style="color: #a0522d;">=</span> 0; <span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span><span style="color: #a020f0;">_</span> <span style="color: #a0522d;">=</span> <span style="color: #a020f0;">_</span><span style="color: #a0522d;">+</span><span style="color: #a020f0;">_</span>; <span style="color: #a0522d;">⋯</span> <span style="color: #707183;">}</span>
<span style="color: #a020f0;">instance</span>
<span style="color: #228b22;">ℕ</span><span style="color: #a0522d;">-</span>tc <span style="color: #228b22;">:</span> <span style="color: #228b22;">HasMonoid</span> <span style="color: #228b22;">ℕ</span>
<span style="color: #228b22;">ℕ</span><span style="color: #a0522d;">-</span>tc <span style="color: #a0522d;">=</span> record <span style="color: #707183;">{</span> <span style="color: #228b22;">Id</span> <span style="color: #a0522d;">=</span> 0; <span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span><span style="color: #a020f0;">_</span> <span style="color: #a0522d;">=</span> <span style="color: #a020f0;">_</span><span style="color: #a0522d;">+</span><span style="color: #a020f0;">_</span>; <span style="color: #a0522d;">⋯</span> <span style="color: #707183;">}</span>
<span style="color: #228b22;">ℕ</span><span style="color: #a0522d;">-</span><span style="color: #228b22;">Σ</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Monoid</span><span style="color: #a0522d;">-</span><span style="color: #228b22;">Σ</span>
<span style="color: #228b22;">ℕ</span><span style="color: #a0522d;">-</span><span style="color: #228b22;">Σ</span> <span style="color: #a0522d;">=</span> <span style="color: #228b22;">ℕ</span> , 0 , <span style="color: #a020f0;">_</span><span style="color: #a0522d;">+</span><span style="color: #a020f0;">_</span> , <span style="color: #a0522d;">⋯</span>
<span style="color: #228b22;">ℕ</span><span style="color: #a0522d;">-</span>pop<span style="color: #a0522d;">-</span>0ᵣ <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span> <span style="color: #707183;">(</span>x y <span style="color: #228b22;">:</span> <span style="color: #228b22;">ℕ</span><span style="color: #707183;">)</span> <span style="color: #a0522d;">→</span> x <span style="color: #a0522d;">+</span> 0 <span style="color: #a0522d;">+</span> y <span style="color: #a0522d;">≡</span> x <span style="color: #a0522d;">+</span> y
<span style="color: #228b22;">ℕ</span><span style="color: #a0522d;">-</span>pop<span style="color: #a0522d;">-</span>0ᵣ <span style="color: #a0522d;">=</span> pop<span style="color: #a0522d;">-</span><span style="color: #228b22;">Idᵣ</span> <span style="color: #228b22;">ℕ</span><span style="color: #a0522d;">-</span>record
<span style="color: #228b22;">ℕ</span><span style="color: #a0522d;">-</span>pop<span style="color: #a0522d;">-</span>0<span style="color: #a0522d;">-</span>tc <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span> <span style="color: #707183;">(</span>x y <span style="color: #228b22;">:</span> <span style="color: #228b22;">ℕ</span><span style="color: #707183;">)</span> <span style="color: #a0522d;">→</span> x <span style="color: #a0522d;">+</span> 0 <span style="color: #a0522d;">+</span> y <span style="color: #a0522d;">≡</span> x <span style="color: #a0522d;">+</span> y
<span style="color: #228b22;">ℕ</span><span style="color: #a0522d;">-</span>pop<span style="color: #a0522d;">-</span>0<span style="color: #a0522d;">-</span>tc <span style="color: #a0522d;">=</span> pop<span style="color: #a0522d;">-</span><span style="color: #228b22;">Id</span><span style="color: #a0522d;">-</span>tc
<span style="color: #228b22;">ℕ</span><span style="color: #a0522d;">-</span>pop<span style="color: #a0522d;">-</span>0<span style="color: #a0522d;">-</span><span style="color: #228b22;">Σ</span> <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span> <span style="color: #707183;">(</span>x y <span style="color: #228b22;">:</span> <span style="color: #228b22;">ℕ</span><span style="color: #707183;">)</span> <span style="color: #a0522d;">→</span> x <span style="color: #a0522d;">+</span> 0 <span style="color: #a0522d;">+</span> y <span style="color: #a0522d;">≡</span> x <span style="color: #a0522d;">+</span> y
<span style="color: #228b22;">ℕ</span><span style="color: #a0522d;">-</span>pop<span style="color: #a0522d;">-</span>0<span style="color: #a0522d;">-</span><span style="color: #228b22;">Σ</span> <span style="color: #a0522d;">=</span> pop<span style="color: #a0522d;">-</span><span style="color: #228b22;">Id</span><span style="color: #a0522d;">-</span><span style="color: #228b22;">Σ</span>
</pre>
</div>
</div> <div style="width:50%;float: left">
</div>
<br> <br> <br> <br> <br>
<p class="fragment (appear)">
⇨ One would expect these <code>pop-0</code> programs <br />
to be instances of <i>one</i> polymorphic function.
</p>
<br>
<p class="fragment (appear)">
⇨ Instead, we currently have three programs that are <br />
instances of <i>three</i> different polymorphic functions.
</p>
</div>
</section>
</section>
<section>
<section id="slide-org95bbb5f">
<h3 id="org95bbb5f">Monoids as Telescopes</h3>
<div style="width:50%;float:left">
<div class="org-src-container">
<pre class="src src-haskell"><span style="color: #a020f0;">module</span> <span style="color: #228b22;">Monoid</span><span style="color: #a0522d;">-</span><span style="color: #228b22;">Telescope</span><span style="color: #a0522d;">-</span><span style="color: #228b22;">User</span>
<span style="color: #707183;">(</span><span style="color: #228b22;">Carrier</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span> <span style="color: #707183;">)</span>
<span style="color: #707183;">(</span><span style="color: #228b22;">Id</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Carrier</span> <span style="color: #707183;">)</span>
<span style="color: #707183;">(</span><span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span><span style="color: #a020f0;">_</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Carrier</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Carrier</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Carrier</span> <span style="color: #707183;">)</span>
<span style="color: #707183;">(</span>lid <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span> <span style="color: #7388d6;">{</span>x<span style="color: #7388d6;">}</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Id</span> <span style="color: #a0522d;">⨾</span> x <span style="color: #a0522d;">≡</span> x <span style="color: #707183;">)</span>
<span style="color: #707183;">(</span>rid <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span> <span style="color: #7388d6;">{</span>x<span style="color: #7388d6;">}</span> <span style="color: #a0522d;">→</span> x <span style="color: #a0522d;">⨾</span> <span style="color: #228b22;">Id</span> <span style="color: #a0522d;">≡</span> x <span style="color: #707183;">)</span>
<span style="color: #707183;">(</span>assoc <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span> x y z <span style="color: #a0522d;">→</span> <span style="color: #7388d6;">(</span>x <span style="color: #a0522d;">⨾</span> y<span style="color: #7388d6;">)</span> <span style="color: #a0522d;">⨾</span> z <span style="color: #a0522d;">≡</span> x <span style="color: #a0522d;">⨾</span> <span style="color: #7388d6;">(</span>y <span style="color: #a0522d;">⨾</span> z<span style="color: #7388d6;">)</span><span style="color: #707183;">)</span>
<span style="color: #a020f0;">where</span>
pop<span style="color: #a0522d;">-</span><span style="color: #228b22;">Id</span><span style="color: #a0522d;">-</span>tel <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span><span style="color: #707183;">(</span>x y <span style="color: #228b22;">:</span> <span style="color: #228b22;">Carrier</span><span style="color: #707183;">)</span> <span style="color: #a0522d;">→</span> <span style="color: #707183;">(</span>x <span style="color: #a0522d;">⨾</span> <span style="color: #228b22;">Id</span><span style="color: #707183;">)</span> <span style="color: #a0522d;">⨾</span> y <span style="color: #a0522d;">≡</span> x <span style="color: #a0522d;">⨾</span> y
pop<span style="color: #a0522d;">-</span><span style="color: #228b22;">Id</span><span style="color: #a0522d;">-</span>tel x y <span style="color: #a0522d;">=</span> cong <span style="color: #707183;">(</span><span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span> y<span style="color: #707183;">)</span> <span style="color: #707183;">(</span>rid <span style="color: #7388d6;">{</span>x<span style="color: #7388d6;">}</span><span style="color: #707183;">)</span>
<span style="color: #0000ff;">open</span> <span style="color: #228b22;">Monoid</span><span style="color: #a0522d;">-</span><span style="color: #228b22;">Telescope</span><span style="color: #a0522d;">-</span><span style="color: #228b22;">User</span> <span style="color: #228b22;">ℕ</span> 0 <span style="color: #a020f0;">_</span><span style="color: #a0522d;">+</span><span style="color: #a020f0;">_</span> <span style="color: #a0522d;">…</span>
<span style="color: #228b22;">ℕ</span><span style="color: #a0522d;">-</span>pop<span style="color: #a0522d;">-</span>tel <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span><span style="color: #707183;">(</span>x y <span style="color: #228b22;">:</span> <span style="color: #228b22;">ℕ</span><span style="color: #707183;">)</span> <span style="color: #a0522d;">→</span> x <span style="color: #a0522d;">+</span> 0 <span style="color: #a0522d;">+</span> y <span style="color: #a0522d;">≡</span> x <span style="color: #a0522d;">+</span> y
<span style="color: #228b22;">ℕ</span><span style="color: #a0522d;">-</span>pop<span style="color: #a0522d;">-</span>tel <span style="color: #a0522d;">=</span> pop<span style="color: #a0522d;">-</span><span style="color: #228b22;">Id</span><span style="color: #a0522d;">-</span>tel
</pre>
</div>
</div> <div style="width:50%;float: left">
<br>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-left">◈</td>
<td class="org-left">Carrier sets, functions, and axioms <i>all</i> are parameters.</td>
</tr>
<tr>
<td class="org-left"> </td>
<td class="org-left"> </td>
</tr>
<tr>
<td class="org-left">◈</td>
<td class="org-left">This parameter listing constitutes a ‘telescope’.</td>
</tr>
</tbody>
</table>
</div>
</section>
</section>
<section>
<section id="slide-org66763ee">
<h3 id="org66763ee">Interdefinability</h3>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-left">⇨</td>
<td class="org-left">Different notions are thus interdefinable</td>
</tr>
<tr>
<td class="org-left">⇨</td>
<td class="org-left">Use-cases <i>distinguish</i> packages</td>
</tr>
<tr>
<td class="org-left">⇨</td>
<td class="org-left">Distinctions ⇒ duplication of efforts</td>
</tr>
</tbody>
</table>
<p class="fragment (appear)">
<b>Generalise!</b> Use a ‘package former’, rather than
a particular variation.
</p>
</section>
</section>
<section>
<section id="slide-org500633d">
<h3 id="org500633d">Foundational Basis: MMT-Style Theory Presentations</h3>
<div class="org-src-container">
<pre class="src src-haskell"><span style="color: #b22222;">-- </span><span style="color: #b22222;">Contexts</span>
<span style="color: #228b22;">Γ</span> <span style="color: #0000ff;">::=</span> <span style="color: #a0522d;">·</span> <span style="color: #b22222;">-- </span><span style="color: #b22222;">empty context</span>
<span style="color: #a0522d;">|</span> x <span style="color: #228b22;">:</span> <span style="color: #228b22;">T</span> <span style="color: #707183;">[</span><span style="color: #228b22;">:=</span> <span style="color: #228b22;">T</span><span style="color: #707183;">]</span>, <span style="color: #228b22;">Γ</span> <span style="color: #b22222;">-- </span><span style="color: #b22222;">context with declaration, optional definition</span>
<span style="color: #a0522d;">|</span> includes <span style="color: #228b22;">X</span>, <span style="color: #228b22;">Γ</span> <span style="color: #b22222;">-- </span><span style="color: #b22222;">theory inclusion</span>
<span style="color: #b22222;">-- </span><span style="color: #b22222;">Terms</span>
<span style="color: #228b22;">T</span> <span style="color: #0000ff;">::=</span> x <span style="color: #a0522d;">|</span> <span style="color: #228b22;">T</span>₁ <span style="color: #228b22;">T</span>₂ <span style="color: #a0522d;">|</span> λ x <span style="color: #228b22;">:</span> <span style="color: #228b22;">T'</span> <span style="color: #a0522d;">•</span> <span style="color: #228b22;">T</span> <span style="color: #b22222;">-- </span><span style="color: #b22222;">variables, application, lambdas</span>
<span style="color: #a0522d;">|</span> <span style="color: #228b22;">Π</span> x <span style="color: #228b22;">:</span> <span style="color: #228b22;">T'</span> <span style="color: #a0522d;">•</span> <span style="color: #228b22;">T</span> <span style="color: #b22222;">-- </span><span style="color: #b22222;">dependent product</span>
<span style="color: #a0522d;">|</span> <span style="color: #707183;">[</span><span style="color: #228b22;">Γ</span><span style="color: #707183;">]</span> <span style="color: #a0522d;">|</span> <span style="color: #707183;">⟨</span><span style="color: #228b22;">Γ</span><span style="color: #707183;">⟩</span> <span style="color: #a0522d;">|</span> T.x <span style="color: #b22222;">-- </span><span style="color: #b22222;">record “[type]” and “⟨element⟩” formers, projections</span>
<span style="color: #a0522d;">|</span> <span style="color: #228b22;">Mod</span> <span style="color: #228b22;">X</span> <span style="color: #b22222;">-- </span><span style="color: #b22222;">contravariant “theory to record” internalisation</span>
<span style="color: #b22222;">-- </span><span style="color: #b22222;">Theory, external grouping, level</span>
<span style="color: #228b22;">Θ</span> <span style="color: #0000ff;">::=</span> <span style="color: #a0522d;">.</span> <span style="color: #b22222;">-- </span><span style="color: #b22222;">empty theory</span>
<span style="color: #a0522d;">|</span> <span style="color: #228b22;">X</span> <span style="color: #228b22;">:=</span> <span style="color: #228b22;">Γ</span>, <span style="color: #228b22;">Θ</span> <span style="color: #b22222;">-- </span><span style="color: #b22222;">a theory can contain named contexts</span>
<span style="color: #a0522d;">|</span> <span style="color: #707183;">(</span><span style="color: #228b22;">X</span> <span style="color: #228b22;">:</span> <span style="color: #7388d6;">(</span><span style="color: #228b22;">X</span>₁ <span style="color: #a0522d;">→</span> <span style="color: #228b22;">X</span>₂<span style="color: #7388d6;">)</span><span style="color: #707183;">)</span> <span style="color: #228b22;">:=</span> <span style="color: #228b22;">Γ</span> <span style="color: #b22222;">-- </span><span style="color: #b22222;">a theory can be a first-class theory morphism</span>
</pre>
</div>
<blockquote class="fragment (appear)">
<p>
A knowledge-capture mechanism
─not a programming environment.
</p>
</blockquote>
<aside class="notes">
<ul>
<li>Theoretical foundations;
we're not inventing from the ground up but want a concrete system.</li>
<li>It is not that it doesn't do what we want,
rather it captures knowledge similar to Wikipedia.</li>
<li>Their setting is more generic than DTLs
and so what we're doing may not even be
feasible there.</li>
<li>It's a theoretical foundation, we intend
to provide concrete tool.</li>
</ul>
</aside>
</section>
</section>
<section>
<section id="slide-org89a716f">
<h2 id="org89a716f">Problem Summary</h2>
<center><table width="80%" border="0""><tr><td>
<p class="fragment (appear)">
😧 :: Coders have to copy-paste-modify packaging structures to obtain
different perspectives.
</p>
<ul>
<li class="fragment appear">E.g., lifting fields to parameters to
ensure correct-by-construction invariants.</li>
<li class="fragment appear">Infrastructure is either rewritten for the new perspective,
or conversion functions are used.</li>
</ul>
<aside class="notes">
<p>
Conversely, one may want to demote parameters to fields so as to be
able to treat a structure heterogeneously.
</p>
<p>
E.g., One may speak of “graphs on” a fixed type, but to speak of
graphs in general, the type cannot be fixed and must be allowed to
vary. One instance of this is constructing a category of graphs.
</p>
</aside>
<p class="fragment (appear)">
😄 :: A package should be written <i>once</i>.
</p>
<ul>
<li class="fragment appear">Desired perspectives are declared on demand.</li>
<li class="fragment appear">Code is written polymorphically along the package, not
a particular perspective.</li>
</ul>
</td><tr></table></center>
</section>
</section>
<section>
<section id="slide-orgb9d1caf">
<h2 id="orgb9d1caf">Desirable Features</h2>
<dl>
<dt class="fragment appear">Uniformity</dt><dd class="fragment appear">Treat different notions of packaging the same way.</dd>
<dt class="fragment appear">Genericity</dt><dd class="fragment appear">Polymorphism along packages types / package formers.</dd>
<dt class="fragment appear">First-class Extensiblity</dt><dd class="fragment appear">Primitives to form new package combinators
<i>using</i> the host language.</dd>
</dl>
</section>
</section>
<section>
<section id="slide-org7c6f4de">
<h2 id="org7c6f4de">We can then have better …</h2>
<ul>
<li>Expressivity
⇒ “Package Polymorphism”</li>
<li>Excerption
⇒ “flattening”</li>
</ul>
</section>
</section>
<section>
<section id="slide-org57f8cf0">
<h3 id="org57f8cf0">Expressivity ─Select Bundling Level</h3>
<center><table width="50%" border="0""><tr><td>
<p>
Which aspects of a structure should be exposed?
</p>
<div class="org-src-container">
<pre class="src src-haskell"><span style="color: #0000ff;">record</span> <span style="color: #228b22;">Semigroup0</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span>₁ <span style="color: #a020f0;">where</span> <span style="color: #a0522d;">…</span>
<span style="color: #0000ff;">record</span> <span style="color: #228b22;">Semigroup1</span> <span style="color: #707183;">(</span><span style="color: #228b22;">Carrier</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span><span style="color: #707183;">)</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span>₁ <span style="color: #a020f0;">where</span> <span style="color: #a0522d;">…</span>
<span style="color: #0000ff;">record</span> <span style="color: #228b22;">Semigroup2</span>
<span style="color: #707183;">(</span><span style="color: #228b22;">Carrier</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span><span style="color: #707183;">)</span>
<span style="color: #707183;">(</span><span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span><span style="color: #a020f0;">_</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Carrier</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Carrier</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Carrier</span><span style="color: #707183;">)</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span> <span style="color: #a020f0;">where</span> <span style="color: #a0522d;">…</span>
<span style="color: #0000ff;">record</span> <span style="color: #228b22;">Semigroup3</span>
<span style="color: #707183;">(</span><span style="color: #228b22;">Carrier</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span><span style="color: #707183;">)</span>
<span style="color: #707183;">(</span><span style="color: #a020f0;">_</span><span style="color: #a0522d;">⨾</span><span style="color: #a020f0;">_</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Carrier</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Carrier</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Carrier</span><span style="color: #707183;">)</span>
<span style="color: #707183;">(</span>assoc <span style="color: #228b22;">:</span> <span style="color: #a0522d;">∀</span> x y z <span style="color: #a0522d;">→</span> <span style="color: #7388d6;">(</span>x <span style="color: #a0522d;">⨾</span> y<span style="color: #7388d6;">)</span> <span style="color: #a0522d;">⨾</span> z <span style="color: #a0522d;">≡</span> x <span style="color: #a0522d;">⨾</span> <span style="color: #7388d6;">(</span>y <span style="color: #a0522d;">⨾</span> z<span style="color: #7388d6;">)</span><span style="color: #707183;">)</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span> <span style="color: #a020f0;">where</span>
<span style="color: #b22222;">-- </span><span style="color: #b22222;">no fields</span>
</pre>
</div>
</td><tr></table></center>
<aside class="notes">
<ul>
<li>Haskell <i>with</i> existential types extension allows Semigroup0.</li>
</ul>
</aside>
</section>
</section>
<section>
<section id="slide-orgf37dc07">
<h3 id="orgf37dc07">Expressivity ─Code along one type, use for another</h3>
<center><table width="50%" border="0""><tr><td>
<p>
We want to code along Semigroup1 and use for <code>Semigroup0</code>.
</p>
<div class="org-src-container">
<pre class="src src-haskell"><span style="color: #b22222;">{- </span><span style="color: #b22222;">Recall -}</span>
<span style="color: #0000ff;">record</span> <span style="color: #228b22;">Semigroup0</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span>₁ <span style="color: #a020f0;">where</span> <span style="color: #a0522d;">…</span>
<span style="color: #0000ff;">record</span> <span style="color: #228b22;">Semigroup1</span> <span style="color: #707183;">(</span><span style="color: #228b22;">Carrier</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span><span style="color: #707183;">)</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span>₁ <span style="color: #a020f0;">where</span> <span style="color: #a0522d;">…</span>
<span style="color: #b22222;">{- </span><span style="color: #b22222;">Write elegantly along Semigroup1 -}</span>
translate1 <span style="color: #0000ff;">:</span> <span style="color: #a0522d;">∀</span><span style="color: #707183;">{</span><span style="color: #228b22;">A</span> <span style="color: #228b22;">B</span><span style="color: #707183;">}</span> <span style="color: #a0522d;">→</span> <span style="color: #707183;">(</span>f <span style="color: #228b22;">:</span> <span style="color: #228b22;">A</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">B</span><span style="color: #707183;">)</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Bijection</span> f
<span style="color: #a0522d;">→</span> <span style="color: #228b22;">Semigroup1</span> <span style="color: #228b22;">A</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Semigroup1</span> <span style="color: #228b22;">B</span>
<span style="color: #b22222;">{- </span><span style="color: #b22222;">Be able to use the previous for Semigroup0 -}</span>
translate0 <span style="color: #0000ff;">:</span> <span style="color: #a0522d;">∀</span><span style="color: #707183;">{</span><span style="color: #228b22;">B</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span><span style="color: #707183;">}</span> <span style="color: #707183;">(</span><span style="color: #228b22;">AS</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Semigroup0</span><span style="color: #707183;">)</span>
<span style="color: #707183;">(</span>f <span style="color: #228b22;">:</span> <span style="color: #228b22;">Semigroup0.Carrier</span> <span style="color: #228b22;">AS</span> <span style="color: #a0522d;">→</span> <span style="color: #228b22;">B</span><span style="color: #707183;">)</span>
<span style="color: #a0522d;">→</span> <span style="color: #228b22;">Bijection</span> f <span style="color: #a0522d;">→</span> <span style="color: #228b22;">Semigroup0</span>
</pre>
</div>
</td><tr></table></center>
</section>
</section>
<section>
<section id="slide-org4f6eb3d">
<h3 id="org4f6eb3d">Excerption ─Instantiating Deeply Nested Theories</h3>
<p>
Can we <i>please</i> just declare a <code>Monad</code> without having to declare
<i>redundant</i> <code>Applicative</code> and <code>Functor</code> instances.
</p>
<br><br>
<div class="org-src-container">
<pre class="src src-haskell"><span style="color: #b22222;">{- </span><span style="color: #b22222;">(0) -}</span> <span style="color: #a020f0;">instance</span> <span style="color: #228b22;">Monad</span> <span style="color: #228b22;">M</span> <span style="color: #a020f0;">where</span> <span style="color: #a0522d;">…</span> <span style="color: #b22222;">-- </span><span style="color: #b22222;">(0) needs (1), which needs (2)</span>
<span style="color: #b22222;">{- </span><span style="color: #b22222;">(1) -}</span> <span style="color: #a020f0;">instance</span> <span style="color: #228b22;">Applicative</span> <span style="color: #228b22;">M</span> <span style="color: #a020f0;">where</span> <span style="color: #a0522d;">…</span> <span style="color: #b22222;">-- </span><span style="color: #b22222;">(1, 2) redundant if (0) is given</span>
<span style="color: #b22222;">{- </span><span style="color: #b22222;">(2) -}</span> <span style="color: #a020f0;">instance</span> <span style="color: #228b22;">Functor</span> <span style="color: #228b22;">M</span> <span style="color: #a020f0;">where</span> <span style="color: #a0522d;">…</span>
</pre>
</div>
<aside class="notes">
<p>
Monad′ ≔ Monad flattenedAlong Applicative
</p>
</aside>
</section>
</section>
<section>
<section id="slide-orgd41b800">
<h3 id="orgd41b800">Excerption ─Instantiating Deeply Nested Theories</h3>
<p>
Accessing deeply nested fields; e.g., <code>Monoid.Semigroup.Magma.Carrier M</code>.
</p>
<a href="example_hierarchy.png"><img src="example_hierarchy.png" alt="Example Hierarchy" width="900" height="580"></a> <br> ⇒ flatten hierarchies!
</section>
</section>
<section>
<section id="slide-orgddfe58d">
<h2 id="orgddfe58d">Related Works</h2>
<div style="width:50%;float:left">
<dl>
<dt>C-family</dt><dd>Records, JSON modules ─everything is explicit</dd>
<dt>Haskell</dt><dd>Single instance typeclasses ─an ‘inference’ mechanism.</dd>
<dt>OCaml</dt><dd>First-class modules are essentially glorified parameters;
enforces a “functor vs. function” dichotomy</dd>
<dt>[Shields, Peyton Jones 2016]</dt><dd><a href="https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/first_class_modules.pdf">First-Class Modules for Haskell</a> <br />
Slightly beyond OCaml, but not far enough.</dd>
</dl>
</div> <div style="width:50%;float: left">
<dl>
<dt>Agda</dt><dd>Dependently-typed typeclasses ─solves diamond problem</dd>
<dt>Coq </dt><dd>Typeclasses with unification;
canonical stuctures triggered by projections</dd>
<dt>Category Theory</dt><dd>Pullbacks! Declared coercions are found
by inference then used in seemingly ill-typed expressions.</dd>
</dl>
<aside class="notes">
<p>
Random notes:
</p>
<ul>
<li>A canonical structure is a declaration of a particular
instance of a record to be used by the type checker
to solve unification problems.</li>
<li>OCaml functors are more or less functions on records in Agda.</li>
<li><p>
Typeclasses are tremendously helpful for having derived constructions
be inferrable, e.g., in Haskell <code>instance f a => f (a ,a)</code> to
produce Cartesian products for some structure <code>f</code> on <code>a</code> provided
there is such a structure on <code>a</code>.
</p>
<p>
One now uses <code>f</code> methods, that act on a homogeneously-typed pair,
and it is inferred that an instance of <code>f a</code> is what is desired
–even though no explicit instance for such a pair type was declared!
Neato ^_^
</p></li>
<li>Coq's unification is essentially Prolog in disguise.</li>
<li>In some sense, I intend to produce Agda package combinators that
are essentially Lisp in disguise.</li>
<li><p>
Solve Diamond Problem using dependent types as follows:
</p>
<div class="org-src-container">
<pre class="src src-haskell"> record <span style="color: #228b22;">X</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span> <span style="color: #a020f0;">where</span> field doit <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span>
record <span style="color: #228b22;">Y</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span> <span style="color: #a020f0;">where</span> field x <span style="color: #228b22;">:</span> <span style="color: #228b22;">X</span>
record <span style="color: #228b22;">Z</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span> <span style="color: #a020f0;">where</span> field x <span style="color: #228b22;">:</span> <span style="color: #228b22;">X</span>
record <span style="color: #228b22;">Ω</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span> <span style="color: #a020f0;">where</span> filed y <span style="color: #228b22;">:</span> <span style="color: #228b22;">Y</span>, z <span style="color: #228b22;">:</span> <span style="color: #228b22;">Z</span>
<span style="color: #b22222;">{- </span><span style="color: #b22222;">We now can refer to two X's, possibly different -}</span>
<span style="color: #b22222;">{- </span><span style="color: #b22222;">Instead, using typeclasses -}</span>
record <span style="color: #228b22;">X</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span> <span style="color: #a020f0;">where</span> field doit <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span>
record <span style="color: #228b22;">Y</span> <span style="color: #707183;">(</span>x <span style="color: #228b22;">:</span> <span style="color: #228b22;">X</span><span style="color: #707183;">)</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span> <span style="color: #a020f0;">where</span>
record <span style="color: #228b22;">Z</span> <span style="color: #707183;">(</span>x <span style="color: #228b22;">:</span> <span style="color: #228b22;">X</span><span style="color: #707183;">)</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span> <span style="color: #a020f0;">where</span>
record <span style="color: #228b22;">Ω</span> <span style="color: #228b22;">:</span> <span style="color: #228b22;">Set</span> <span style="color: #a020f0;">where</span> filed x <span style="color: #228b22;">:</span> <span style="color: #228b22;">X</span>, y <span style="color: #228b22;">:</span> <span style="color: #228b22;">Y</span> x, z <span style="color: #228b22;">:</span> <span style="color: #228b22;">Z</span> x
</pre>
</div>
<p>
With dependent types, <code>X</code> can be lifted to be any telescope of functions
that cold conflict ^_^
</p></li>
</ul>
</aside>
<aside class="notes">
<div class="org-src-container">
<pre class="src src-haskell"> x <span style="color: #a0522d;">*</span> <span style="color: #707183;">(</span>y <span style="color: #a0522d;">+</span> z<span style="color: #707183;">)</span> well<span style="color: #a0522d;">-</span>typed
<span style="color: #a0522d;">⇐</span> Group._<span style="color: #a0522d;">*</span><span style="color: #a020f0;">_</span> <span style="color: #a0522d;">?</span><span style="color: #228b22;">G</span> x <span style="color: #707183;">(</span>Monoid._<span style="color: #a0522d;">+</span><span style="color: #a020f0;">_</span> <span style="color: #a0522d;">?</span><span style="color: #228b22;">M</span> y z<span style="color: #707183;">)</span> well<span style="color: #a0522d;">-</span>typed
<span style="color: #a0522d;">⇐</span> <span style="color: #228b22;">Group.Carrier</span> <span style="color: #a0522d;">?</span><span style="color: #228b22;">G</span> <span style="color: #a0522d;">≡</span> <span style="color: #228b22;">Monoid.Carrier</span> <span style="color: #a0522d;">?</span><span style="color: #228b22;">M</span>
<span style="color: #a0522d;">⇐</span> <span style="color: #a0522d;">?</span><span style="color: #228b22;">G</span> <span style="color: #a0522d;">=</span> <span style="color: #228b22;">Ring.Group</span> <span style="color: #a0522d;">?</span><span style="color: #228b22;">R</span><span style="color: #88090B;">)</span> <span style="color: #a0522d;">∧</span> <span style="color: #a0522d;">?</span><span style="color: #228b22;">M</span> <span style="color: #a0522d;">≡</span> <span style="color: #228b22;">Ring.Monoid</span> <span style="color: #a0522d;">?</span><span style="color: #228b22;">R</span>
</pre>
</div>
</aside>
</div>
</section>
</section>
<section>
<section id="slide-org4497031">
<h2 id="org4497031">Competing works?</h2>
<h3>
<p class="fragment (appear)">
<i>There are none!</i>
</p>
</h3>
</section>
</section>
<section>
<section id="slide-org3f7c07d">
<h2 id="org3f7c07d">Visualisation of Parts of the Proposed “Package Polymorphism”</h2>
<iframe width="1000" height="700" src="https://www.youtube.com/embed/NYOOF9xKBz8?version=3&autoplay=1&mute=1&loop=1" frameborder="0" allowfullscreen></iframe>
<aside class="notes">
<p>
</p>
<ul>
<li>One writes the ‘red’ code with the intent that it will
<i>behave</i> like the ‘blue’ code.</li>
<li>Unless requested, no code is ‘generated’.</li>
<li>This' akin to <code>deriving</code> in Haskell.</li>
</ul>
</aside>
</section>
</section>
<section>
<section id="slide-org95bd3a7">
<h2 id="org95bd3a7">Why can't this be done now?</h2>