either.h
Exposes functions for processing Either objects, which can represent values of two types.
- Author: Edward Jones
- Date: 2021-09-17
dest_either
Destroy an either-type object.
- Param
e
: Pointer to the either object to destroy - Param
led
: Element destructor for the left - Param
red
: Element destructor for the right
void dest_either(Either* e, Destructor led, Destructor red);
fmap_either
Fmap over either-type object.
- Param
eo
: Output either type - Param
ei
: Input Either type - Param
f
: Function to apply to the contents ofei
to produceeo
void fmap_either(Either* eo, Either* ei, Fmap f);
make_either_left
Construct an either-type object with the left constructor.
- Param
e
: Pointer to the either object to initialise - Param
left_val
: Value to place into the left constructor
void make_either_left(Either* e, void* left_val);
make_either_right
Construct an either-type object with the right constructor.
- Param
e
: Pointer to the either object to initialise - Param
right_val
: Value to place into the right constructor
void make_either_right(Either* e, void* right_val);
succ_either
Return whether a given either-type object represents a successful result.
- Param
e
: Pointer to the either object to check
Returns: true if e uses the right constructor otherwise false
bool succ_either(Either* e);