| About the Author |
|
ix | |
| About the Technical Reviewer |
|
xi | |
| Introduction |
|
xiii | |
|
Chapter 1 Rescript Basics |
|
|
1 | (28) |
|
Expressions, Values, and Side Effects |
|
|
1 | (1) |
|
|
|
2 | (1) |
|
Types, Typechecking, and Type Inference |
|
|
2 | (1) |
|
Primitive Types and Operators |
|
|
3 | (5) |
|
|
|
3 | (2) |
|
|
|
5 | (1) |
|
|
|
6 | (1) |
|
|
|
7 | (1) |
|
|
|
8 | (1) |
|
|
|
9 | (3) |
|
|
|
10 | (2) |
|
|
|
12 | (2) |
|
|
|
14 | (1) |
|
|
|
14 | (2) |
|
|
|
16 | (5) |
|
|
|
21 | (3) |
|
|
|
24 | (3) |
|
|
|
27 | (2) |
|
|
|
29 | (24) |
|
Defining and Using Functions |
|
|
29 | (14) |
|
|
|
31 | (1) |
|
Using Standard Library Functions and Opening Modules |
|
|
32 | (2) |
|
|
|
34 | (1) |
|
|
|
35 | (3) |
|
Labeled and Optional Parameters |
|
|
38 | (2) |
|
Currying and Partial Application |
|
|
40 | (2) |
|
|
|
42 | (1) |
|
|
|
43 | (3) |
|
|
|
44 | (2) |
|
|
|
46 | (6) |
|
|
|
46 | (2) |
|
|
|
48 | (4) |
|
|
|
52 | (1) |
|
Chapter 3 Composite Data Types |
|
|
53 | (34) |
|
|
|
53 | (2) |
|
|
|
54 | (1) |
|
|
|
55 | (6) |
|
Pattern Matching with Tuples |
|
|
57 | (4) |
|
|
|
61 | (11) |
|
Declaring and Constructing Variants |
|
|
61 | (1) |
|
Pattern Matching with Variants |
|
|
62 | (1) |
|
|
|
62 | (1) |
|
|
|
63 | (1) |
|
|
|
64 | (5) |
|
|
|
69 | (3) |
|
|
|
72 | (1) |
|
|
|
73 | (3) |
|
Exceptions and Error Handling |
|
|
76 | (1) |
|
|
|
77 | (1) |
|
|
|
77 | (1) |
|
|
|
78 | (8) |
|
Another Way to Handle Errors: Result |
|
|
79 | (2) |
|
|
|
81 | (1) |
|
Defining Errors for Results |
|
|
82 | (2) |
|
|
|
84 | (2) |
|
|
|
86 | (1) |
|
Chapter 4 Records and Objects |
|
|
87 | (22) |
|
|
|
87 | (14) |
|
Declaring and Creating Records |
|
|
88 | (1) |
|
|
|
88 | (1) |
|
|
|
89 | (1) |
|
|
|
90 | (1) |
|
|
|
91 | (1) |
|
|
|
91 | (1) |
|
|
|
92 | (3) |
|
Pattern Matching with Records |
|
|
95 | (2) |
|
|
|
97 | (2) |
|
|
|
99 | (1) |
|
|
|
100 | (1) |
|
|
|
101 | (7) |
|
Declaring and Creating Objects |
|
|
102 | (1) |
|
|
|
103 | (1) |
|
|
|
103 | (1) |
|
|
|
104 | (1) |
|
|
|
105 | (1) |
|
|
|
106 | (2) |
|
|
|
108 | (1) |
|
Chapter 5 Lists and Arrays |
|
|
109 | (32) |
|
|
|
109 | (1) |
|
|
|
110 | (3) |
|
|
|
111 | (2) |
|
Higher-Order Functions for Arrays |
|
|
113 | (15) |
|
|
|
113 | (3) |
|
|
|
116 | (2) |
|
|
|
118 | (4) |
|
Composing Higher-Order Functions |
|
|
122 | (1) |
|
Higher-Order Functions in Action |
|
|
122 | (4) |
|
Generalizing Higher-Order Functions |
|
|
126 | (2) |
|
|
|
128 | (5) |
|
|
|
128 | (1) |
|
|
|
129 | (1) |
|
Pattern Matching with List |
|
|
130 | (3) |
|
Higher-Order Functions with Lists |
|
|
133 | (8) |
|
|
|
136 | (1) |
|
Use Cases for Immutable Collections |
|
|
137 | (2) |
|
|
|
139 | (1) |
|
|
|
139 | (2) |
|
|
|
141 | (32) |
|
|
|
142 | (14) |
|
|
|
143 | (3) |
|
|
|
146 | (3) |
|
Using Collections: Luggage Example Revisited |
|
|
149 | (2) |
|
Advanced Topic: Generic Collections |
|
|
151 | (5) |
|
|
|
156 | (15) |
|
|
|
157 | (2) |
|
|
|
159 | (2) |
|
Mutable Set and Mutable Map |
|
|
161 | (1) |
|
|
|
162 | (2) |
|
Advanced Topic: Generic Hash Set/Hash Map Keys |
|
|
164 | (3) |
|
|
|
167 | (4) |
|
Which Collection Should I Use? |
|
|
171 | (2) |
|
|
|
173 | (30) |
|
|
|
174 | (1) |
|
|
|
174 | (1) |
|
|
|
175 | (7) |
|
|
|
177 | (4) |
|
|
|
181 | (1) |
|
|
|
182 | (6) |
|
|
|
188 | (12) |
|
|
|
189 | (1) |
|
Defining Module Signatures |
|
|
189 | (5) |
|
|
|
194 | (1) |
|
Defining and Using Functors |
|
|
195 | (2) |
|
|
|
197 | (2) |
|
Functors in the Standard Library |
|
|
199 | (1) |
|
|
|
200 | (3) |
|
Chapter 8 JavaScript Interoperability |
|
|
203 | (52) |
|
Calling JavaScript from Rescript |
|
|
203 | (5) |
|
Embedding Raw JavaScript in Rescript Files |
|
|
206 | (2) |
|
Calling Rescript from JavaScript |
|
|
208 | (3) |
|
Exporting Values from Rescript |
|
|
208 | (1) |
|
Using Rescript Modules from JavaScript |
|
|
209 | (2) |
|
|
|
211 | (5) |
|
|
|
213 | (1) |
|
|
|
214 | (1) |
|
|
|
215 | (1) |
|
|
|
216 | (4) |
|
Immutable Data Structures |
|
|
216 | (1) |
|
|
|
216 | (3) |
|
|
|
219 | (1) |
|
|
|
220 | (3) |
|
|
|
223 | (2) |
|
Catching Rescript Exceptions in JavaScript |
|
|
223 | (2) |
|
Catching JavaScript Exceptions in Rescript |
|
|
225 | (1) |
|
|
|
225 | (7) |
|
Option 1 Binding Without Types |
|
|
225 | (2) |
|
Option 2 Binding With Types |
|
|
227 | (1) |
|
|
|
228 | (4) |
|
Putting It All Together: Simple Rescript Web App |
|
|
232 | (21) |
|
Version 1 Handwritten Bindings |
|
|
233 | (14) |
|
Version 2 Using Imported Bindings |
|
|
247 | (6) |
|
|
|
253 | (2) |
| Index |
|
255 | |