Merge pull request #213650 from urandom2/libdoc

lib: standardise attrset type syntax

Changed files
+10 -10
lib
+5 -5
lib/attrsets.nix
···
] { a.b.c = 0; }
=> { a = { b = { d = 1; }; }; x = { y = "xy"; }; }
-
Type: updateManyAttrsByPath :: [{ path :: [String], update :: (Any -> Any) }] -> AttrSet -> AttrSet
+
Type: updateManyAttrsByPath :: [{ path :: [String]; update :: (Any -> Any); }] -> AttrSet -> AttrSet
*/
updateManyAttrsByPath = let
# When recursing into attributes, instead of updating the `path` of each
···
=> { name = "some"; value = 6; }
Type:
-
nameValuePair :: String -> Any -> { name :: String, value :: Any }
+
nameValuePair :: String -> Any -> { name :: String; value :: Any; }
*/
nameValuePair =
# Attribute name
···
=> { foo_x = "bar-a"; foo_y = "bar-b"; }
Type:
-
mapAttrs' :: (String -> Any -> { name = String; value = Any }) -> AttrSet -> AttrSet
+
mapAttrs' :: (String -> Any -> { name :: String; value :: Any; }) -> AttrSet -> AttrSet
*/
mapAttrs' =
# A function, given an attribute's name and value, returns a new `nameValuePair`.
···
Example:
zipAttrsWith (name: values: values) [{a = "x";} {a = "y"; b = "z";}]
-
=> { a = ["x" "y"]; b = ["z"] }
+
=> { a = ["x" "y"]; b = ["z"]; }
Type:
zipAttrsWith :: (String -> [ Any ] -> Any) -> [ AttrSet ] -> AttrSet
···
Example:
zipAttrs [{a = "x";} {a = "y"; b = "z";}]
-
=> { a = ["x" "y"]; b = ["z"] }
+
=> { a = ["x" "y"]; b = ["z"]; }
Type:
zipAttrs :: [ AttrSet ] -> AttrSet
+2 -2
lib/lists.nix
···
/* Splits the elements of a list in two lists, `right` and
`wrong`, depending on the evaluation of a predicate.
-
Type: (a -> bool) -> [a] -> { right :: [a], wrong :: [a] }
+
Type: (a -> bool) -> [a] -> { right :: [a]; wrong :: [a]; }
Example:
partition (x: x > 2) [ 5 1 2 3 4 ]
···
/* Merges two lists of the same size together. If the sizes aren't the same
the merging stops at the shortest.
-
Type: zipLists :: [a] -> [b] -> [{ fst :: a, snd :: b}]
+
Type: zipLists :: [a] -> [b] -> [{ fst :: a; snd :: b; }]
Example:
zipLists [ 1 2 ] [ "a" "b" ]
+3 -3
lib/options.nix
···
You can omit the default path if the name of the option is also attribute path in nixpkgs.
-
Type: mkPackageOption :: pkgs -> string -> { default :: [string], example :: null | string | [string] } -> option
+
Type: mkPackageOption :: pkgs -> string -> { default :: [string]; example :: null | string | [string]; } -> option
Example:
mkPackageOption pkgs "hello" { }
···
/* Extracts values of all "value" keys of the given list.
-
Type: getValues :: [ { value :: a } ] -> [a]
+
Type: getValues :: [ { value :: a; } ] -> [a]
Example:
getValues [ { value = 1; } { value = 2; } ] // => [ 1 2 ]
···
/* Extracts values of all "file" keys of the given list
-
Type: getFiles :: [ { file :: a } ] -> [a]
+
Type: getFiles :: [ { file :: a; } ] -> [a]
Example:
getFiles [ { file = "file1"; } { file = "file2"; } ] // => [ "file1" "file2" ]