002: Intro to Opaque Types

April 03, 2020 0:40:00 38.66 MB Downloads: 0

Opaque Types

Some patterns

  • Runtime validations - conditionally return type, wrapped in Result or Maybe
  • Guarantee constraints through the exposed API of the module (like PositiveInteger or AuthToken examples)

Package-Opaque Modules

Example - the Element type in elm-ui.
Definition of the Element type alias

elm-ui's elm.json file does not expose the internal module where the real Element type is defined.

Example from elm-graphql codebase - CamelCaseName opaque type