diff options
author | Marvin Borner | 2024-11-06 15:18:17 +0100 |
---|---|---|
committer | Marvin Borner | 2024-11-06 15:18:17 +0100 |
commit | 3f149e2807c2249487b0a1583b266859a557c694 (patch) | |
tree | 0873f3a309d7c37e4fcc27ce44b3bfb486cfdd79 /std/Result.bruijn | |
parent | 8dbf9ed690e0c0393a81e014e2861a93288ae42c (diff) |
Minor improvements
Diffstat (limited to 'std/Result.bruijn')
-rw-r--r-- | std/Result.bruijn | 10 |
1 files changed, 10 insertions, 0 deletions
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']) |