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