diff options
author | makefu <github@syntax-fehler.de> | 2015-10-17 11:18:55 +0200 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2015-10-17 11:18:55 +0200 |
commit | 2454867a529ab44f22c9e1c51e3642ac4c391bad (patch) | |
tree | aa0aa4d81cd95046cce98ff770642f6c21fb31b2 /krebs/4lib/maybe.nix | |
parent | f83b3770dd401004bef0233c3de0eb07686788a5 (diff) | |
parent | 4d32e1575705e544c8cbb5834447d71c1b577970 (diff) |
Merge remote-tracking branch 'cd/master'
Diffstat (limited to 'krebs/4lib/maybe.nix')
-rw-r--r-- | krebs/4lib/maybe.nix | 10 |
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); +} |