Creating Modules
Just as there’s not a lot to defining records, there’s not much to the basics of modules. In fact, we’ve been working with modules all along—any re file is automatically a module, as we saw when we put the shirt size data type and its associated functions in a separate file. You can also create a module within a file by using the keyword module, the module name (which must begin with a capital letter), an equal sign, and then code in braces. Anything you could put in a ReasonML file can be in a module definition.
So let’s expand our type definitions and add utility functions for converting to and from strings in our types, each of which will be in its own mini-module. First, let’s look at the Size module:
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access