// In Reason, code is mainly structured in immutable record types (compiled to JS objects), // functions and modules... it uses only a few features, but due to functional composition it's very easy // to build more complex structures (encapsulation etc). Less to learn, more power to the user! // Playground Link: // https://reasonml.github.io/en/try?rrjsx=true&reason=LYewJgrgNgpgBAVQM4wE5wLxwN4Cg5wD0AVHAOrxgwBmAlgHYxhwCGcqMAxiKmADRwA7gAtanYQJD04nDiwAutKQMZM48kHGEsAbjHwEWUKK3nzUtAEYR5MJHAAOHFPXkA6D3CS1gtKC1QoAE91TTZOfyR7bnokcwhODXRiQgN5IId4eUwcAwJ6FmAYAC4vcwYAcz48uBhgFj9SuIt6KoMAXwBuAwMSOABRPVQg+VFW2qgUOFp7ACsIONY4agh6RKVpQVpRhjgQCHQAA2Q0Q7hQSFg8gElpahZEgR37LeNWN-MWWP9bUK8fBywZardZSGRGSasejMABSAGU9pZZlx5PZdqN4DBoXAUgZYNkKhwYNksBBMAA+OAwpBuKAgCoACgARAAJWhwJlwADUXLgEDcBSKAEpugQ8cSZFJ5A8SXyKVSaXTGUz+vU-JUOdzefy6g0oCLcF1cLg+gAVYTwOioRYKcrWX7HFCoAWFGBnWzGewYyXABx+NDqbTZQTwALwbTQqAatjpTJ5LY7aTek7oC7QeBIbiZHGpfGS4Y5PAEFMuoqlJkAYR4QSZ1QIusaHO4wwAAnJErNM1IkNBFK03NxgEzDd0TaR+gBHCC0HRGLHZDSIJ0DqUyhnNoJCjxuWpDEZjCrTOYLbJsFZrRRg3EbgC05JLMWliU6QA module User = { // We defined a record, which, on creation, need to have // all attributes present... similarly to a class constructor type t = { name: string, email: string, }; // Everything else is just a function within our `User` module // In fact, this will all translate to simple function calls and JS objects in the end let greet = u => Js.log("Hi " ++ u.name); let contact = u => Js.log("Emailing " ++ u.email); }; // The first attribute `User.name` tells the compiler that we are handling a type // within the User module scope let cory = { User.name: "Cory", email: "cory@reactjsconsulting.com" }; // Equivalent to User.contact(cory)... everything is just a function cory->User.contact;