From 6ff66fcbd70c7d588bbf6e3b2cd41aa7d8a62fd2 Mon Sep 17 00:00:00 2001 From: Colin Arnott Date: Mon, 30 Jan 2023 21:22:02 +0000 Subject: lib: standardise attrset type syntax There are a number of different syntaxes used for attrset type signatures in our doc strings, this change standardises upon one that uses :: for specifying attribute type, and ; terminators to be consistent with nix syntax. There are no bugs in the functions themselves, just that different syntaxes may confuse new users. --- lib/attrsets.nix | 10 +++++----- lib/lists.nix | 4 ++-- lib/options.nix | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/attrsets.nix b/lib/attrsets.nix index 1a51225a80ed5..30952651adf40 100644 --- a/lib/attrsets.nix +++ b/lib/attrsets.nix @@ -168,7 +168,7 @@ rec { ] { 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 @@ -414,7 +414,7 @@ rec { => { name = "some"; value = 6; } Type: - nameValuePair :: String -> Any -> { name :: String, value :: Any } + nameValuePair :: String -> Any -> { name :: String; value :: Any; } */ nameValuePair = # Attribute name @@ -449,7 +449,7 @@ rec { => { 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`. @@ -649,7 +649,7 @@ rec { 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 @@ -664,7 +664,7 @@ rec { Example: zipAttrs [{a = "x";} {a = "y"; b = "z";}] - => { a = ["x" "y"]; b = ["z"] } + => { a = ["x" "y"]; b = ["z"]; } Type: zipAttrs :: [ AttrSet ] -> AttrSet diff --git a/lib/lists.nix b/lib/lists.nix index 8b2c2d12801bb..9f69485b40862 100644 --- a/lib/lists.nix +++ b/lib/lists.nix @@ -306,7 +306,7 @@ rec { /* 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 ] @@ -374,7 +374,7 @@ rec { /* 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" ] diff --git a/lib/options.nix b/lib/options.nix index ce66bfb9d5d9f..d14d209a83471 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -114,7 +114,7 @@ rec { 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" { } @@ -201,7 +201,7 @@ rec { /* 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 ] @@ -211,7 +211,7 @@ rec { /* 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" ] -- cgit 1.4.1