about summary refs log tree commit diff
path: root/default.nix
diff options
context:
space:
mode:
authorAlex Rice <alexrice999@hotmail.co.uk>2019-09-19T14·33+0100
committerVincent Ambo <github@tazj.in>2019-09-19T14·56+0100
commit13cc0d3d4814b4871b0e03fc0a522c135f3607e6 (patch)
treed62151ae02d43aa806d47aee1e3795135f3703fa /default.nix
parent7b1e389c664bca731be8ba66730be946a904d84c (diff)
feat: add n-ary either
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix6
1 files changed, 4 insertions, 2 deletions
diff --git a/default.nix b/default.nix
index 9cd09e644028..2167b6e8b71f 100644
--- a/default.nix
+++ b/default.nix
@@ -123,8 +123,10 @@ in lib.fix (self: {
       };
   };
 
-  either = t1: t2: typedef "either<${t1.name},${t2.name}>"
-    (x: (self.type t1).check x || (self.type t2).check x);
+  eitherN = tn: typedef "either<${concatStringsSep ", " (map (x: x.name) tn)}>"
+    (x: any (t: (self.type t).check x) tn);
+
+  either = t1: t2: self.eitherN [ t1 t2 ];
 
   list = t: typedef' rec {
     name = "list<${t.name}>";