summaryrefslogtreecommitdiffstats
path: root/krebs/4lib
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2015-10-17 11:18:55 +0200
committermakefu <github@syntax-fehler.de>2015-10-17 11:18:55 +0200
commit2454867a529ab44f22c9e1c51e3642ac4c391bad (patch)
treeaa0aa4d81cd95046cce98ff770642f6c21fb31b2 /krebs/4lib
parentf83b3770dd401004bef0233c3de0eb07686788a5 (diff)
parent4d32e1575705e544c8cbb5834447d71c1b577970 (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);
+}