diff options
author | Eric Sagnes <eric.sagnes@gmail.com> | 2016-11-07 08:34:06 +0900 |
---|---|---|
committer | Bjørn Forsman <bjorn.forsman@gmail.com> | 2016-11-08 20:46:34 +0100 |
commit | cf2654b2e0dedd31c6ec14458953c85530db8cec (patch) | |
tree | b072a073f143447bc49df163811b99782be4c399 /lib/types.nix | |
parent | 0ba3d429a758cec15545fc11c9d3fd1424c5c5f8 (diff) |
either type: improve merge function
Diffstat (limited to 'lib/types.nix')
-rw-r--r-- | lib/types.nix | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/types.nix b/lib/types.nix index 26523f59f256..9366d394da73 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -333,7 +333,15 @@ rec { name = "either"; description = "${t1.description} or ${t2.description}"; check = x: t1.check x || t2.check x; - merge = mergeOneOption; + merge = loc: defs: + let + defList = map (d: d.value) defs; + in + if all (x: t1.check x) defList + then t1.merge loc defs + else if all (x: t2.check x) defList + then t2.merge loc defs + else mergeOneOption loc defs; typeMerge = f': let mt1 = t1.typeMerge (elemAt f'.wrapped 0).functor; mt2 = t2.typeMerge (elemAt f'.wrapped 1).functor; |