Add a 'functionTo x' type.

This is mainly to for the 'merge' concept, but I made a guess as to what
iter and fold would mean for functions.
This commit is contained in:
Shea Levy 2012-12-19 22:49:21 -05:00
parent bbffdd4702
commit ce6d4070a6

View file

@ -176,6 +176,19 @@ rec {
fold = op: nul: v: if v == null then nul else elemType.fold op nul v;
};
functionTo = elemType: mkOptionType {
name = "function that evaluates to a(n) ${elemType.name}";
check = lib.traceValIfNot builtins.isFunction;
merge = fns:
args: elemType.merge (map (fn: fn args) fns)
# These are guesses, I don't fully understand iter, fold, delayOnGlobalEval
iter = f: path: v:
args: elemType.iter f path (v args);
fold = op: nul: v:
args: elemType.fold op nul (v args);
inherit (elemType) hasOptions delayOnGlobalEval;
};
# !!! this should be a type constructor that takes the options as
# an argument.
optionSet = mkOptionType {