February 2019
Beginner to intermediate
180 pages
4h 4m
English
The Reason standard library's Array module contains several functions, but not all the ones you'd expect coming from JavaScript. It does have a map function, however:
/* Reason standard library */let array = [|"first", "second", "third"|];Array.map(e => e ++ "-mapped", array);
The type of Array.map is as follows:
('a => 'b, array('a)) => array('b);
The type signature says map accepts a function of type 'a => 'b, an array of type 'a, and returns an array of type 'b. Note that, 'a and 'b are type variables. Type variables are like normal variables, except for types. In the preceding example, map has a type:
(string => string, array(string)) => array(string);
This is because the 'a and 'b type variables were ...
Read now
Unlock full access