Metalang99 1.13.3
Full-blown preprocessor metaprogramming
maybe.h File Reference

An optional value. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ML99_just(x)   ML99_call(ML99_just, x)
 Some value x.
 
#define ML99_nothing(...)   ML99_callUneval(ML99_nothing, )
 No value.
 
#define ML99_isJust(maybe)   ML99_call(ML99_isJust, maybe)
 ML99_true() if maybe contains some value, otherwise ML99_false(). More...
 
#define ML99_isNothing(maybe)   ML99_call(ML99_isNothing, maybe)
 The inverse of ML99_isJust. More...
 
#define ML99_maybeEq(cmp, maybe, other)   ML99_call(ML99_maybeEq, cmp, maybe, other)
 Tests maybe and other for equality. More...
 
#define ML99_maybeUnwrap(maybe)   ML99_call(ML99_maybeUnwrap, maybe)
 Returns the contained value on ML99_just(x) or emits a fatal error on ML99_nothing(). More...
 
#define ML99_JUST(x)   ML99_CHOICE(just, x)
 
#define ML99_NOTHING(...)   ML99_CHOICE(nothing, ~)
 
#define ML99_IS_JUST(maybe)   ML99_PRIV_IS_JUST(maybe)
 
#define ML99_IS_NOTHING(maybe)   ML99_NOT(ML99_IS_JUST(maybe))
 

Detailed Description

An optional value.

Macro Definition Documentation

◆ ML99_isJust

#define ML99_isJust (   maybe)    ML99_call(ML99_isJust, maybe)

ML99_true() if maybe contains some value, otherwise ML99_false().

Examples

// 1
// 0
#define v(...)
A value that is pasted as-is; no evaluation occurs on provided arguments.
Definition: lang.h:145
An optional value.
#define ML99_nothing(...)
No value.
Definition: maybe.h:23
#define ML99_isJust(maybe)
ML99_true() if maybe contains some value, otherwise ML99_false().
Definition: maybe.h:40
#define ML99_just(x)
Some value x.
Definition: maybe.h:18

◆ ML99_isNothing

#define ML99_isNothing (   maybe)    ML99_call(ML99_isNothing, maybe)

The inverse of ML99_isJust.

Examples

// 1
// 0
#define ML99_isNothing(maybe)
The inverse of ML99_isJust.
Definition: maybe.h:57

◆ ML99_maybeEq

#define ML99_maybeEq (   cmp,
  maybe,
  other 
)    ML99_call(ML99_maybeEq, cmp, maybe, other)

Tests maybe and other for equality.

Examples

#include <metalang99/nat.h>
// 1
// 0
// 0
#define ML99_maybeEq(cmp, maybe, other)
Tests maybe and other for equality.
Definition: maybe.h:78
Natural numbers: [0; 255].
#define ML99_natEq(x, y)
Definition: nat.h:112

◆ ML99_maybeUnwrap

#define ML99_maybeUnwrap (   maybe)    ML99_call(ML99_maybeUnwrap, maybe)

Returns the contained value on ML99_just(x) or emits a fatal error on ML99_nothing().

Examples

// 123
// Emits a fatal error.
#define ML99_maybeUnwrap(maybe)
Returns the contained value on ML99_just(x) or emits a fatal error on ML99_nothing().
Definition: maybe.h:95