Added `makeExtensibleWithInterface`
This commit is contained in:
parent
2c1097a83b
commit
08021dd825
|
@ -71,8 +71,19 @@ rec {
|
||||||
|
|
||||||
# Same as `makeExtensible` but the name of the extending attribute is
|
# Same as `makeExtensible` but the name of the extending attribute is
|
||||||
# customized.
|
# customized.
|
||||||
makeExtensibleWithCustomName = extenderName: rattrs:
|
makeExtensibleWithCustomName = extenderName: makeExtensibleWithInterface
|
||||||
fix' rattrs // {
|
(fixedPoint: extend: fixedPoint // { ${extenderName} = extend; });
|
||||||
${extenderName} = f: makeExtensibleWithCustomName extenderName (extends f rattrs);
|
|
||||||
};
|
# Similar to `makeExtensible`, but expects you to implement the
|
||||||
|
# final interface for the result. Specifically, it takes an extra
|
||||||
|
# argument: a function that takes the final result and the `extend`
|
||||||
|
# function as arguments, and returns a transformed result
|
||||||
|
# (preferably one that contains the `extend` function). This is
|
||||||
|
# mainly useful for getting to choose what to name the `extend`
|
||||||
|
# function in the resulting attribute set. But it's also useful for
|
||||||
|
# having an internal structure that extensions can see, but the user
|
||||||
|
# facing code cannot.
|
||||||
|
makeExtensibleWithInterface = interface: fext: interface
|
||||||
|
(fix' fext)
|
||||||
|
(f: makeExtensibleWithInterface interface (extends f fext));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue