summaryrefslogtreecommitdiffstats
path: root/krebs/4lib
diff options
context:
space:
mode:
authorlassulus <lass@aidsballs.de>2015-10-17 15:59:58 +0200
committerlassulus <lass@aidsballs.de>2015-10-17 15:59:58 +0200
commit21b6854a15a827850b50040f52c853ca8ba56024 (patch)
tree2a45e2393be9980d0c485dc6cf726d1601454a04 /krebs/4lib
parent62af75a108efa64683532f949110bf412ffecfd9 (diff)
parent8cfdca6b6d6eed24953c1259b11239260e5a849f (diff)
Merge remote-tracking branch 'cd/master'
Diffstat (limited to 'krebs/4lib')
-rw-r--r--krebs/4lib/maybe.nix10
1 files changed, 10 insertions, 0 deletions
diff --git a/krebs/4lib/maybe.nix b/krebs/4lib/maybe.nix
new file mode 100644
index 000000000..5189c99a1
--- /dev/null
+++ b/krebs/4lib/maybe.nix
@@ -0,0 +1,10 @@
+{ ... }:
+
+rec {
+ Just = x: { type = "maybe"; value = x; };
+ Nothing = { type = "maybe"; };
+ isMaybe = x: builtins.typeOf x == "set" && x.type or false == "maybe";
+ isJust = x: isMaybe x && builtins.hasAttr "value" x;
+ fromJust = x: assert isJust x; x.value;
+ catMaybes = xs: map fromJust (builtins.filter isJust xs);
+}