maybe.h¶
An optional value.
Defines
-
ML99_just(x)¶
Some value
x
.
-
ML99_nothing(...)¶
No value.
-
ML99_isJust(maybe)¶
ML99_true()
ifmaybe
contains some value, otherwiseML99_false()
.Examples
#include <metalang99/maybe.h> // 1 ML99_isJust(ML99_just(v(123))) // 0 ML99_isJust(ML99_nothing())
-
ML99_isNothing(maybe)¶
The inverse of ML99_isJust.
Examples
#include <metalang99/maybe.h> // 1 ML99_isNothing(ML99_nothing()) // 0 ML99_isNothing(ML99_just(v(123)))
-
ML99_maybeEq(cmp, maybe, other)¶
Tests
maybe
andother
for equality.Examples
#include <metalang99/maybe.h> #include <metalang99/nat.h> // 1 ML99_maybeEq(v(ML99_natEq), ML99_just(v(123)), ML99_just(v(123))); // 0 ML99_maybeEq(v(ML99_natEq), ML99_just(v(4)), ML99_just(v(6))); // 0 ML99_maybeEq(v(ML99_natEq), ML99_just(v(4)), ML99_nothing());
-
ML99_maybeUnwrap(maybe)¶
Returns the contained value on
ML99_just(x)
or emits a fatal error onML99_nothing()
.Examples
#include <metalang99/maybe.h> // 123 ML99_maybeUnwrap(ML99_just(v(123))) // Emits a fatal error. ML99_maybeUnwrap(ML99_nothing())
-
ML99_JUST(x)¶
-
ML99_NOTHING(...)¶
-
ML99_IS_JUST(maybe)¶
-
ML99_IS_NOTHING(maybe)¶