3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request from urandom2/libdoc

lib: standardise attrset type syntax
This commit is contained in:
Silvan Mosberger 2023-01-31 16:20:56 +01:00 committed by GitHub
commit 96d4702261
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 10 deletions

View file

@ -168,7 +168,7 @@ rec {
] { a.b.c = 0; } ] { a.b.c = 0; }
=> { a = { b = { d = 1; }; }; x = { y = "xy"; }; } => { 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 updateManyAttrsByPath = let
# When recursing into attributes, instead of updating the `path` of each # When recursing into attributes, instead of updating the `path` of each
@ -414,7 +414,7 @@ rec {
=> { name = "some"; value = 6; } => { name = "some"; value = 6; }
Type: Type:
nameValuePair :: String -> Any -> { name :: String, value :: Any } nameValuePair :: String -> Any -> { name :: String; value :: Any; }
*/ */
nameValuePair = nameValuePair =
# Attribute name # Attribute name
@ -449,7 +449,7 @@ rec {
=> { foo_x = "bar-a"; foo_y = "bar-b"; } => { foo_x = "bar-a"; foo_y = "bar-b"; }
Type: Type:
mapAttrs' :: (String -> Any -> { name = String; value = Any }) -> AttrSet -> AttrSet mapAttrs' :: (String -> Any -> { name :: String; value :: Any; }) -> AttrSet -> AttrSet
*/ */
mapAttrs' = mapAttrs' =
# A function, given an attribute's name and value, returns a new `nameValuePair`. # A function, given an attribute's name and value, returns a new `nameValuePair`.
@ -649,7 +649,7 @@ rec {
Example: Example:
zipAttrsWith (name: values: values) [{a = "x";} {a = "y"; b = "z";}] zipAttrsWith (name: values: values) [{a = "x";} {a = "y"; b = "z";}]
=> { a = ["x" "y"]; b = ["z"] } => { a = ["x" "y"]; b = ["z"]; }
Type: Type:
zipAttrsWith :: (String -> [ Any ] -> Any) -> [ AttrSet ] -> AttrSet zipAttrsWith :: (String -> [ Any ] -> Any) -> [ AttrSet ] -> AttrSet
@ -664,7 +664,7 @@ rec {
Example: Example:
zipAttrs [{a = "x";} {a = "y"; b = "z";}] zipAttrs [{a = "x";} {a = "y"; b = "z";}]
=> { a = ["x" "y"]; b = ["z"] } => { a = ["x" "y"]; b = ["z"]; }
Type: Type:
zipAttrs :: [ AttrSet ] -> AttrSet zipAttrs :: [ AttrSet ] -> AttrSet

View file

@ -306,7 +306,7 @@ rec {
/* Splits the elements of a list in two lists, `right` and /* Splits the elements of a list in two lists, `right` and
`wrong`, depending on the evaluation of a predicate. `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: Example:
partition (x: x > 2) [ 5 1 2 3 4 ] 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 /* Merges two lists of the same size together. If the sizes aren't the same
the merging stops at the shortest. the merging stops at the shortest.
Type: zipLists :: [a] -> [b] -> [{ fst :: a, snd :: b}] Type: zipLists :: [a] -> [b] -> [{ fst :: a; snd :: b; }]
Example: Example:
zipLists [ 1 2 ] [ "a" "b" ] zipLists [ 1 2 ] [ "a" "b" ]

View file

@ -114,7 +114,7 @@ rec {
You can omit the default path if the name of the option is also attribute path in nixpkgs. 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: Example:
mkPackageOption pkgs "hello" { } mkPackageOption pkgs "hello" { }
@ -201,7 +201,7 @@ rec {
/* Extracts values of all "value" keys of the given list. /* Extracts values of all "value" keys of the given list.
Type: getValues :: [ { value :: a } ] -> [a] Type: getValues :: [ { value :: a; } ] -> [a]
Example: Example:
getValues [ { value = 1; } { value = 2; } ] // => [ 1 2 ] getValues [ { value = 1; } { value = 2; } ] // => [ 1 2 ]
@ -211,7 +211,7 @@ rec {
/* Extracts values of all "file" keys of the given list /* Extracts values of all "file" keys of the given list
Type: getFiles :: [ { file :: a } ] -> [a] Type: getFiles :: [ { file :: a; } ] -> [a]
Example: Example:
getFiles [ { file = "file1"; } { file = "file2"; } ] // => [ "file1" "file2" ] getFiles [ { file = "file1"; } { file = "file2"; } ] // => [ "file1" "file2" ]