The first improvement we can make is to create a module to contain the record for the web apps and a function that would return their string representation. Let's call that module WebApp. Its definition is as follows:
module WebApp = {
type t = {
name: string,
url: string,
};
let toString = (app: t) => app.name ++ " (" ++ app.url ++ ")" ;
}
Then, as in the previous version, we have our example web app values. The only thing that changes is that the type annotation is done using WebApp.t. That part of the code is as follows:
let facebook: WebApp.t = {
name: "facebook",
url: "https://facebook.com",
}
let facebookads: WebApp.t = {
name: "facebook ads",
url: "https://www.facebook.com/business",
}
let messenger: WebApp.t = {
name: "messenger",
url: "...