blob: 5189c99a110969de7455c5cc794a266f18602dda (
plain)
1
2
3
4
5
6
7
8
9
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);
}
|