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

A choice type with two cases. More...

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

Go to the source code of this file.

Macros

#define ML99_left(x)   ML99_call(ML99_left, x)
 The left value x.
 
#define ML99_right(x)   ML99_call(ML99_right, x)
 The right value x.
 
#define ML99_isLeft(either)   ML99_call(ML99_isLeft, either)
 ML99_true() if either contains a left value, otherwise ML99_false(). More...
 
#define ML99_isRight(either)   ML99_call(ML99_isRight, either)
 The inverse of ML99_isLeft. More...
 
#define ML99_eitherEq(cmp, either, other)   ML99_call(ML99_eitherEq, cmp, either, other)
 Tests either and other for equality. More...
 
#define ML99_unwrapLeft(either)   ML99_call(ML99_unwrapLeft, either)
 Returns the left value on ML99_left(x) or emits a fatal error on ML99_right(y). More...
 
#define ML99_unwrapRight(either)   ML99_call(ML99_unwrapRight, either)
 The inverse of ML99_unwrapLeft. More...
 
#define ML99_LEFT(x)   ML99_CHOICE(left, x)
 
#define ML99_RIGHT(x)   ML99_CHOICE(right, x)
 
#define ML99_IS_LEFT(either)   ML99_PRIV_IS_LEFT(either)
 
#define ML99_IS_RIGHT(either)   ML99_NOT(ML99_IS_LEFT(either))
 

Detailed Description

A choice type with two cases.

Macro Definition Documentation

◆ ML99_eitherEq

#define ML99_eitherEq (   cmp,
  either,
  other 
)    ML99_call(ML99_eitherEq, cmp, either, other)

Tests either and other for equality.

Examples

#include <metalang99/nat.h>
// 1
// 0
// 0
A choice type with two cases.
#define ML99_right(x)
The right value x.
Definition: either.h:23
#define ML99_left(x)
The left value x.
Definition: either.h:18
#define ML99_eitherEq(cmp, either, other)
Tests either and other for equality.
Definition: either.h:78
#define v(...)
A value that is pasted as-is; no evaluation occurs on provided arguments.
Definition: lang.h:145
Natural numbers: [0; 255].
#define ML99_natEq(x, y)
Definition: nat.h:112

◆ ML99_isLeft

#define ML99_isLeft (   either)    ML99_call(ML99_isLeft, either)

ML99_true() if either contains a left value, otherwise ML99_false().

Examples

// 1
// 0
#define ML99_isLeft(either)
ML99_true() if either contains a left value, otherwise ML99_false().
Definition: either.h:40

◆ ML99_isRight

#define ML99_isRight (   either)    ML99_call(ML99_isRight, either)

The inverse of ML99_isLeft.

Examples

// 1
// 0
#define ML99_isRight(either)
The inverse of ML99_isLeft.
Definition: either.h:57

◆ ML99_unwrapLeft

#define ML99_unwrapLeft (   either)    ML99_call(ML99_unwrapLeft, either)

Returns the left value on ML99_left(x) or emits a fatal error on ML99_right(y).

Examples

// 123
// Emits a fatal error.
#define ML99_unwrapLeft(either)
Returns the left value on ML99_left(x) or emits a fatal error on ML99_right(y).
Definition: either.h:95

◆ ML99_unwrapRight

#define ML99_unwrapRight (   either)    ML99_call(ML99_unwrapRight, either)

The inverse of ML99_unwrapLeft.

Examples

// 123
// Emits a fatal error.
#define ML99_unwrapRight(either)
The inverse of ML99_unwrapLeft.
Definition: either.h:112