aboutsummaryrefslogtreecommitdiff
path: root/src/std/bool.gleam
diff options
context:
space:
mode:
Diffstat (limited to 'src/std/bool.gleam')
-rw-r--r--src/std/bool.gleam38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/std/bool.gleam b/src/std/bool.gleam
new file mode 100644
index 0000000..985f0d6
--- /dev/null
+++ b/src/std/bool.gleam
@@ -0,0 +1,38 @@
+import std/order
+
+pub fn negate(bool) {
+ case bool {
+ | True -> False
+ | False -> True
+ }
+}
+
+pub fn compare(a, b) {
+ case {a, b} {
+ | {True, True} -> order:Eq
+ | {True, False} -> order:Gt
+ | {False, False} -> order:Eq
+ | {False, True} -> order:Lt
+ }
+}
+
+pub fn max(a, b) {
+ case a {
+ | True -> True
+ | False -> b
+ }
+}
+
+pub fn min(a, b) {
+ case a {
+ | False -> False
+ | True -> b
+ }
+}
+
+pub fn to_int(bool) {
+ case bool {
+ | False -> 0
+ | True -> 1
+ }
+}