Our first example demonstrates how to define methods on struct types in PureScript.
In PureScript, we use records instead of structs. Methods are defined as separate functions that take the record as their first argument.
PureScript is a purely functional language, so we don’t have the concept of pointer receivers or value receivers. Instead, functions always operate on immutable data.
To run this program, you would typically compile it to JavaScript and then run it with Node.js:
Next, we’ll explore PureScript’s type classes, which provide a way to define interfaces for polymorphic functions.