I wanted to make fix
and makeScope
a built in operator in my language and this is the way I'm going to do it:
myident @ {
foo = 132;
bar = myident.foo;
}
This behaves the way you expect it to, just like fix
. But you can also override the bind:
{
needsBaz = self @ { bar = self.baz; };
} ==> {
bazzed = setMeta { bind = (getMeta needsBaz).bind // { baz = 123; } needsBaz;
}
So you can leverage this to implement anything, basically. Also the bind in foo @ { pattern, here }: here
will act specially and bind to the argument instead of the lambda itself. So it is basically identical to the Nix version here.
Further, when you do inputs @ { ... } ==> ...
, the bind inputs
will bind to the "use"d attribute set, and it will get overriden by the language itself when the "use"d attribute set gets overriden. So it will all work magically.
Last updated: Oct 12 2024 at 21:45 UTC