docs: migrate lib.points to doc-comments

This commit is contained in:
KFears 2025-09-14 22:48:52 +04:00
parent efca3387c5
commit f76e162e21
Signed by: KFearsoff
SSH key fingerprint: SHA256:sn39ts1xvi/KGQNlqDyrj8nNlhp9ilndgIolXKnPraw

View file

@ -1,10 +1,16 @@
lib: {
## Calculate the fixed point of a function. This will evaluate the function `f`
## until its result settles (or Nix's recursion limit is reached). This allows
## us to define recursive functions without worrying about the order of their
## definitions.
##
## @type (a -> a) -> a
/**
Calculate the fixed point of a function. This will evaluate the function `f`
until its result settles (or Nix's recursion limit is reached). This allows
us to define recursive functions without worrying about the order of their
definitions.
# Type
```
fix :: (a -> a) -> a
```
*/
fix =
f:
let
@ -12,13 +18,19 @@ lib: {
in
x;
## Calculate the fixed point of a function. This will evaluate the function `f`
## until its result settles (or Nix's recursion limit is reached). This allows
## us to define recursive functions without worrying about the order of their
## definitions. Unlike `fix`, the resulting value is also given a `__unfix__`
## attribute that is set to the original function passed to `fix'`.
##
## @type (a -> a) -> a & { __unfix__ :: (a -> a) }
/**
Calculate the fixed point of a function. This will evaluate the function `f`
until its result settles (or Nix's recursion limit is reached). This allows
us to define recursive functions without worrying about the order of their
definitions. Unlike `fix`, the resulting value is also given a `__unfix__`
attribute that is set to the original function passed to `fix'`.
# Type
```
fix' :: (a -> a) -> a & { __unfix__ :: (a -> a) }
```
*/
fix' =
f:
let
@ -28,10 +40,16 @@ lib: {
in
x;
## Extend a function's output with an additional function. This is the basis for
## features like overlays.
##
## @type (a -> b -> c) -> (a -> b) -> a -> b & c
/**
Extend a function's output with an additional function. This is the basis for
features like overlays.
# Type
```
extends :: (a -> b -> c) -> (a -> b) -> a -> b & c
```
*/
extends =
g: f: self:
let
@ -40,9 +58,15 @@ lib: {
in
previous // next;
## Add an `extend` method to the result of a function.
##
## @type (a -> b) -> b & { extend :: (a -> b -> c) -> b & c }
/**
Add an `extend` method to the result of a function.
# Type
```
withExtend :: (a -> b) -> b & { extend :: (a -> b -> c) -> b & c }
```
*/
withExtend =
f:
let