Skip to content

Commit 647cb4a

Browse files
committed
More slides
1 parent 8e0c414 commit 647cb4a

File tree

4 files changed

+49
-31
lines changed

4 files changed

+49
-31
lines changed

algebraic-data-types/project/plugins.sbt

Whitespace-only changes.

algebraic-data-types/src/main/tut/index.html

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
font-family: 'Yanone Kaffeesatz';
1313
font-weight: normal;
1414
}
15-
small .MathJax_Display {
15+
small .MathJax_Display, small .remark-code {
1616
font-size: small;
1717
}
1818
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
@@ -31,9 +31,14 @@
3131

3232
# Index
3333

34-
1. **Algebraic Data Types**.
35-
1. **Free Algebras**.
36-
1. **Equational Reasoning** at the program level.
34+
1. **Data Types**.
35+
* Algebraic data types.
36+
* Generalized algebraic data types.
37+
* Sum and product data types.
38+
1. **Algebras**.
39+
* Boolean Algebra
40+
* Free Algebra
41+
1. ~~**Equational Reasoning** at the program level.~~
3742

3843
---
3944

@@ -54,8 +59,6 @@
5459

5560
# Algebraic Data Types
5661

57-
An algebraic data type is a missnomer.
58-
5962
An algebraic data type is not *just* a data type, it's a data type *plus* an
6063
algebra.
6164

@@ -85,7 +88,7 @@
8588
```
8689

8790
In the context of scala, case classes come with their own `apply` and `unapply`
88-
for a pattern matching algebra.
91+
for a structural (pattern matching) algebra.
8992

9093
<small>
9194
(If you look at regular expressions in pattern matching you might be pleasently
@@ -94,6 +97,43 @@
9497

9598
---
9699

100+
# Generalized Algebraic Data Type
101+
102+
As long as you trust inheritance
103+
104+
<small>
105+
```tut
106+
sealed abstract trait Lam[A] {def a: A}
107+
case class Lift[A](a: A) extends Lam[A]
108+
case class Tup[A, B](_a: A, b: B) extends Lam[(A, B)] {def a = (_a, b)}
109+
case class Lamda[A, B](f: Lam[A] => Lam[B]) extends Lam[A => B] {
110+
def a = { _a => f(Lift(_a)).a }
111+
}
112+
case class App[A, B](f: Lam[A => B], _a: Lam[A]) extends Lam[B] {def a = f.a(_a.a)}
113+
case class Fix[A](f: Lam[A => A]) extends Lam[A] {
114+
def a = Fix(Lift(_a => f.a(_a))).a
115+
}
116+
```
117+
</small>
118+
119+
---
120+
121+
# Sum Types and Product Types
122+
123+
Structurally:
124+
125+
```tut
126+
type Sum[A] = Lam[A] // Lift ∨ Tup ∨ Lambda ∨ App ∨ Fix
127+
type Prod[A, B] = Tup[A, B] // A ∧ B
128+
type Prod2[A, B] = (Lam[A], Lam[B]) // Lam[A] ∧ Lam[B]
129+
```
130+
131+
<small>
132+
[Sum and Product types as encoded by Shapeless 2.1.0](https://github.com/milessabin/shapeless/wiki/Feature-overview:-shapeless-2.1.0)
133+
</small>
134+
135+
---
136+
97137
# Boolean Algebra
98138

99139
Boolean algebra satisfies many of the same laws as arithmetic when one
@@ -143,6 +183,8 @@
143183

144184
* [Algebraic Data Types](http://tpolecat.github.io/presentations/algebraic_types.html)
145185
by Rob Norris (@tpolecat)
186+
* [Shapeless 2.1.0 Feature Overview](https://github.com/milessabin/shapeless/wiki/Feature-overview:-shapeless-2.1.0)
187+
* [I am not a monad, I am a free algebra](http://biosimilarity.blogspot.com/2011/08/i-am-not-monad-i-am-free-algebra-pt-1.html)
146188
* [Sweeping crap APIs under the rug](http://tpolecat.github.io/presentations/lambdaconf14.html)
147189
by Rob Norris (@tpolecat)
148190

algebraic-data-types/src/main/tut/javascript/math-jax.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

algebraic-data-types/src/main/tut/javascript/remark-latest.min.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)