February 2019
Beginner to intermediate
180 pages
4h 4m
English
Let's imagine that we're building an invoice-management system and we have an Invoice module that defines an invoice type along with a function that other modules can use to create values of that type. This arrangement is shown in the following code:
/* Invoice.re */type t = { name: string, email: string, date: Js.Date.t, total: float};let make = (~name, ~email, ~date, ~total) => { name, email, date, total};
Let's also suppose that we have another module that is responsible for sending emails to customers, as shown in the following code:
/* Email.re */let send = invoice: Invoice.t => ...let invoice = Invoice.make( ~name="Raphael", ~email="persianturtle@gmail.com", ~date=Js.Date.make(), ~total=15.0, );send(invoice); ...
Read now
Unlock full access