From 3f149e2807c2249487b0a1583b266859a557c694 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 6 Nov 2024 15:18:17 +0100 Subject: Minor improvements --- std/Result.bruijn | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'std/Result.bruijn') 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']) -- cgit v1.2.3