2024-06-01 04:00:53 -07:00
|
|
|
lib: {
|
|
|
|
bools = {
|
|
|
|
into = {
|
2024-06-03 02:57:13 -07:00
|
|
|
## Convert a boolean value into a string.
|
|
|
|
##
|
|
|
|
## @type Bool -> String
|
2024-06-01 04:00:53 -07:00
|
|
|
string = value:
|
|
|
|
if value
|
|
|
|
then "true"
|
|
|
|
else "false";
|
2024-06-03 02:57:13 -07:00
|
|
|
|
|
|
|
## Convert a boolean into either the string "yes" or "no".
|
|
|
|
##
|
|
|
|
## @type Bool -> String
|
|
|
|
yesno = value:
|
|
|
|
if value
|
|
|
|
then "yes"
|
|
|
|
else "no";
|
2024-06-01 04:00:53 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
## Choose between two values based on a condition. When true, the first value
|
|
|
|
## is returned, otherwise the second value is returned.
|
|
|
|
##
|
|
|
|
## @type Bool -> a -> b -> a | b
|
|
|
|
when = condition: x: y:
|
|
|
|
if condition
|
|
|
|
then x
|
|
|
|
else y;
|
|
|
|
|
|
|
|
## Perform a logical AND operation on two values.
|
|
|
|
##
|
|
|
|
## @type Bool -> Bool -> Bool
|
|
|
|
and = a: b: a && b;
|
|
|
|
|
|
|
|
## Perform a logical AND operation on two functions being applied to a value.
|
|
|
|
##
|
|
|
|
## @type (a -> Bool) -> (a -> Bool) -> a -> Bool
|
|
|
|
and' = f: g: (
|
|
|
|
x: (f x) && (g x)
|
|
|
|
);
|
|
|
|
|
|
|
|
## Perform a logical OR operation on two values.
|
|
|
|
##
|
|
|
|
## @type Bool -> Bool -> Bool
|
|
|
|
or = a: b: a || b;
|
|
|
|
|
|
|
|
## Perform a logical OR operation on two functions being applied to a value.
|
|
|
|
##
|
|
|
|
## @type (a -> Bool) -> (a -> Bool) -> a -> Bool
|
|
|
|
or' = f: g: (
|
|
|
|
x: (f x) || (g x)
|
|
|
|
);
|
|
|
|
|
|
|
|
## Perform a logical NOT operation on a value.
|
|
|
|
##
|
|
|
|
## @type Bool -> Bool
|
|
|
|
not = a: !a;
|
|
|
|
};
|
|
|
|
}
|