Do you have 20+ fields of configuration for your kitchen sink API? This approach might be for you.
An approach to specifying many (required) fields, where some are defaulted. What you get:
- The ability to specify what the defaults are in a single place.
- That set of defaults is decoupled from the function that uses the record (separating concerns).
- The ability to choose different sets of defaults easily (e.g. "dev" mode vs "production" mode).
- Type-safety; you can't specify defaults for required fields as an API provider.
- Overriding: you can provide values instead of using the default trivially.
- Light-weight syntax.
- Failing to provide a required field as an API end-user results in a type error.
A field which has no sensible default value (such as one enabling a new feature like TLSSettings
) can still be Maybe a
.