Funnily enough, cluncs and the do operator are easily implemented in nix (Merging attribute sets is quite important in nix). Only problem is that nix doesn’t support even the most basic numeric operations (like sqrt, pow (so I gave up on implementing your causal examples)).
let
do = model: overrides: let self = model (self // overrides); in self;
quad = self: {
x = 4;
constant = 3;
linear = 2 * self.x + self.constant;
result = self.x * self.x + self.linear;
};
quadDefault = do quad { };
quad2 = do quad { x = 2; };
quadNoLinear = do quad { linear = 0; };
in {
default = quadDefault.result;
overridden = quad2.result;
noLinear = quadNoLinear.result;
}
Funnily enough, cluncs and the do operator are easily implemented in nix (Merging attribute sets is quite important in nix). Only problem is that nix doesn’t support even the most basic numeric operations (like sqrt, pow (so I gave up on implementing your causal examples)).