aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--std/Number/Unary.bruijn2
-rw-r--r--std/Option.bruijn9
-rw-r--r--std/Result.bruijn10
3 files changed, 20 insertions, 1 deletions
diff --git a/std/Number/Unary.bruijn b/std/Number/Unary.bruijn
index 96fef9a..c372983 100644
--- a/std/Number/Unary.bruijn
+++ b/std/Number/Unary.bruijn
@@ -18,7 +18,7 @@ uid [[[extract (2 inc init)]]] ⧗ Unary → Unary
:test (uid (+5u)) ((+5u))
# returns true if a unary number is zero
-zero? [0 [(+0u)] true] ⧗ Unary → Boolean
+zero? [0 [false] true] ⧗ Unary → Boolean
=?‣ zero?
diff --git a/std/Option.bruijn b/std/Option.bruijn
index a6323d2..36387c2 100644
--- a/std/Option.bruijn
+++ b/std/Option.bruijn
@@ -50,3 +50,12 @@ result-or [[0 [[0 3]] [[[1 2]]]]]
:test (result-or "fail" none) ([[0 "fail"]])
:test (result-or "fail" (some "ok")) ([[1 "ok"]])
+
+pure some ⧗ a → (Option a)
+
+bind [[1 1 0]] ⧗ (Option a) → (a → (Option b)) → (Option a)
+
+…>>=… bind
+
+:test (none >>= (pure "idk")) (none)
+:test ((some 'a') >>= [pure [1]]) (some ['a'])
diff --git a/std/Result.bruijn b/std/Result.bruijn
index 838032c..51eabdc 100644
--- a/std/Result.bruijn
+++ b/std/Result.bruijn
@@ -1,4 +1,5 @@
# MIT License, Copyright (c) 2022 Marvin Borner
+# TODO: the type signatures are wrong :)
:import std/Combinator .
:import std/Logic .
@@ -61,3 +62,12 @@ apply [[1 0 err]] ⧗ (Result a) → (a → b) → (Result b)
:test (apply (err [[0]]) [ok ([[1]] 0)]) (err [[0]])
:test (apply (ok [[0]]) [ok ([[1]] 0)]) (ok [[[0]]])
+
+pure ok ⧗ a → (Result a)
+
+bind [[1 0 err]] ⧗ (Result a) → (a → (Result b)) → (Result a)
+
+…>>=… bind
+
+:test ((err 'a') >>= (pure "idk")) (err 'a')
+:test ((ok 'a') >>= [pure [1]]) (ok ['a'])