Skip to content
Ivan Pidhurskyi edited this page Nov 26, 2025 · 1 revision

Maybe Type

type maybe(T) = Some(T) | Nothing()

Represents an optional value that may or may not be present.

Constructors:

  • Some(value) - Wraps a value
  • Nothing() - Represents absence of value

Operations:

  • unpack(maybe) - Extract value or raise error if Nothing
  • expect(maybe, message) - Extract value or raise error with custom message
  • unpack_or(maybe, default) - Extract value or return default if Nothing
  • bool(maybe) - Convert to boolean (true for Some, false for Nothing)

Clone this wiki locally