From 745147f88f400cced478dd588a2dfd7a7c2140a8 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Mon, 18 Jul 2022 01:44:38 +0200 Subject: Moved/improved standard library and other things --- std/Result.bruijn | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 std/Result.bruijn (limited to 'std/Result.bruijn') diff --git a/std/Result.bruijn b/std/Result.bruijn new file mode 100644 index 0000000..28b8181 --- /dev/null +++ b/std/Result.bruijn @@ -0,0 +1,21 @@ +# MIT License, Copyright (c) 2022 Marvin Borner + +:import std/Combinator . + +# encapsulates a value in ok +ok [[[1 2]]] +:test ok [[0]] = [[1 [[0]]]] + +# encapsulates a value in err +err [[[0 2]]] +:test err [[0]] = [[0 [[0]]]] + +# checks whether result is ok +ok? [0 [T] [F]] +:test ok? (ok [[0]]) = T +:test ok? (err [[0]]) = F + +# checks whether result is not ok +err? [0 [F] [T]] +:test err? (ok [[0]]) = F +:test err? (err [[0]]) = T -- cgit v1.2.3