User-Defined Types
Beyond the built-in primitives and collections, mimas lets you define your own named types. There are two kinds, and they cover the classic algebraic pair:
- Structs — product types. A struct holds several values at once: a
Playerhas a name and a score and a position. - Enums — sum types. An enum is exactly one of several shapes: a
Shapeis a circle or a rectangle or a triangle, never more than one.
Both gain behavior through impl blocks, and both can satisfy a pact to share an interface.