This commit is contained in:
Jeff Hykin 2024-05-25 12:13:51 -04:00
parent 11c40a8dcf
commit 9cb4ed1ffc

View file

@ -1,5 +1,5 @@
{ lib, ... }:
rec {
{ foldr }:
let
/*
`fix f` computes the fixed point of the given function `f`. In other words, the return value is `x` in `x = f x`.
@ -274,7 +274,16 @@ rec {
```
*/
composeManyExtensions =
lib.foldr (x: y: composeExtensions x y) (final: prev: {});
foldr (x: y: composeExtensions x y) (final: prev: {});
/*
Same as `makeExtensible` but the name of the extending attribute is
customized.
*/
makeExtensibleWithCustomName = extenderName: rattrs:
fix' (self: (rattrs self) // {
${extenderName} = f: makeExtensibleWithCustomName extenderName (extends f rattrs);
});
/*
Create an overridable, recursive attribute set. For example:
@ -297,13 +306,14 @@ rec {
```
*/
makeExtensible = makeExtensibleWithCustomName "extend";
/*
Same as `makeExtensible` but the name of the extending attribute is
customized.
*/
makeExtensibleWithCustomName = extenderName: rattrs:
fix' (self: (rattrs self) // {
${extenderName} = f: makeExtensibleWithCustomName extenderName (extends f rattrs);
});
}
in
{
fix = fix;
fix' = fix';
converge = converge;
extends = extends;
composeExtensions = composeExtensions;
composeManyExtensions = composeManyExtensions;
makeExtensibleWithCustomName = makeExtensibleWithCustomName;
makeExtensible = makeExtensible;
}