Chapter 2Writing Functions
ReasonML is a functional programming language, which allows you to take advantage of the many benefits of that programming style. Pure functions (functions that have no side effects) make debugging and testing easier. You never have to worry about your function changing some global state, which, in turn, makes things like concurrent and asynchronous code much easier to write.
This chapter is concerned mostly with the mechanics of writing functions. We’ll look at syntax shortcuts and labeled parameters that let you specify arguments by name rather than order. We’ll also discuss how ReasonML’s type inference automatically checks that our functions’ parameters and results have the right types. Though, as you’ll see, ...
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