-
Notifications
You must be signed in to change notification settings - Fork 1
/
typescript-vs-haskell.html
131 lines (103 loc) · 2.51 KB
/
typescript-vs-haskell.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>TypeScript vs Haskell</title>
<meta name="description" content="Structural vs nominal type systems">
<style>
:root {
font-size: 95%;
--accent: rgb(147, 63, 24);
}
@media (prefers-color-scheme: dark) {
:root {
--accent: rgb(222, 219, 42);
}
body {
background-color: rgb(12, 17, 23);
color: rgb(224, 224, 234);
}
}
body {
margin-block-start: 4em;
margin-block-end: 0;
padding-block-end: 20svh;
margin-inline: 0;
--margin-inline: 4rem;
line-height: 1.5;
font-family: system-ui, sans-serif;
}
@media (width < 40em) {
body {
margin-block-start: 1em;
--margin-inline: 1rem;
}
}
p {
margin-block: 2.25em;
max-width: 34rem;
}
h2, b, em {
color: var(--accent);
}
header {
h2 {
margin-block-end: 0
}
p {
margin-block-start: 0.5em;
opacity: 0.6;
font-size: 0.93rem;
font-style: italic;
}
margin-block-end: 3.325rem;
}
h2, p {
margin-inline: var(--margin-inline);
}
hr {
border: 0;
border-bottom: 1px solid var(--accent);
padding-block-start: 20svh;
margin-block: 4rem;
}
body {
border-bottom: 1px solid var(--accent);
}
</style>
</head>
<body>
<header>
<h2>TypeScript vs Haskell</h2>
<p>When a rose by any other name would do</p>
</header>
<p>
TypeScript provides <b>structural typing</b>. If it walks like a duck, and
quacks like a duck, for TypeScript, it is a duck. TypeScript does not care at
all what name you give to the type.
</p>
<p>
Haskell provides <b>nominal typing</b>. It must be called a duck for it to be
considered a duck. A rose by any other name won’t do.
</p>
<hr>
<p>
Both TypeScript and Haskell are based on solid, grounded, mathematics that goes
back a century at least. It is not programmers hacking these languages together
on whim and fashion (though that plays a part) - it is more of people trying to
transmute the hard nuggets of type theory into practical programming languages.
</p>
<p>
Both TypeScript and Haskell provide type inference. Which means that <em>you
won’t need to</em> tell the compiler the type of a duck or a rose, it’ll just
know.
</p>
<p>
But the surprising thing is, after a while <em>you’ll want to</em> write the
types. Programming in these languages then becomes the game of describing the
types and how they transform into each other (as opposed to more direct approach
of describing values and how they transform into each other).
</p>
</body>
</html>