lib: mkIfElse

This commit is contained in:
Zynh Ludwig 2024-08-24 19:51:44 -07:00
parent 2540156e17
commit f4ec471ef5

View file

@ -1,6 +1,6 @@
final: prev: final: prev:
let let
inherit (prev) isFunction; inherit (prev) isFunction mkMerge mkIf;
in in
rec { rec {
# Ternary operator # Ternary operator
@ -15,4 +15,9 @@ rec {
right = f: g: tern (isFunction g) right = f: g: tern (isFunction g)
(right (x: f (g (x)))) (right (x: f (g (x))))
(f (g)); (f (g));
mkIfElse = predicate: yes: no: mkMerge [
(mkIf predicate yes)
(mkIf (!predicate) no)
];
} }