~
~
.
$
How many values inhibit each of these?
Type | Possibilities |
---|---|
() | ? |
O | ? |
H' | ? |
(H', H') | ? |
()
()
1
()
O
O
1
O
H'
H'
3
H¹
H²
H³
(H', H')
(H', H')
9
(H¹, H¹)
(H¹, H²)
(H¹, H³)
(H², H¹)
(H², H²)
(H², H³)
(H³, H¹)
(H³, H²)
(H³, H³)
(H', Bool)
(H', Bool)
6
(H¹, True)
(H¹, False)
(H², True)
(H², False)
(H³, True)
(H³, False)
Type | Inhibitants |
---|---|
() | 1 |
Bool | 2 |
H' | 3 |
A | a |
B | b |
(A, B) | a × b |
A | B | a + b |
Product types Π
Type | Inhibitants |
---|---|
() | 1 |
Bool | 2 |
((), Bool) | 1 × 2 = 2 |
(H’, Bool) | 3 × 2 = 6 |
Sum types Σ
Type | Inhibitants |
---|---|
() | 1 |
Bool | 2 |
() | Bool | 1 + 2 = 3 |
H’ | Bool | 3 + 2 = 5 |
Why not both?
Why not both?
Member | Inhibitants |
---|---|
CrazyA a | a |
CrazyB b | b |
Both a b | a × b |
Neither | 1 |
Σ | a + b + a × b + 1 |
Can there be a “0”?
Can there be a “0”?
Yes
Σ = 0 + 1 + 0 × 1 + 1 = 2
How do lists fit into this?
How do lists fit into this?
x = 1 + a * x
Element name | Color |
---|---|
Helium | orange |
Neon | red |
Argon | lavender |
Krypton | white |
Xenon | blue |
Radon | red |
How to convert noble gases to color?
What about allowing everything in?
What about treating noble gases as a sum type?
a -> String
^
???
^
Noble -> String
~
Works:
Doesn’t work:
Any “box” can go in 👍
(no animals were harmed in the making of this slideshow)
What’s a Mappable
?
It’s a Functor
It’s a Functor
It’s a Functor
It’s a Functor
It’s a Functor
What’s a Appliable
?
It’s an Applicative
It’s an Applicative
It’s an Applicative
What’s a Chainable
?
It’s a monad
It’s a monad
It’s a monad