Commit e394a579 authored by İlkecan Bozdoğan's avatar İlkecan Bozdoğan
Browse files

lib: update type signatures

- concrete types start with uppercase: Int, String, Bool, Derivation,
  etc.
- type variables start with lowercase: a, b, etc.
- list:
  - use `[x]` for homogeneous lists instead of `List x` or `[ x ]`
  - use `List` for heterogeneous lists (not that common in `lib`)
- attr:
  - use `AttrSet` for a generic attribute set type
  - use `{ key1 :: Type1; key2 :: Type2; ... }` for adding signatures
    for known attribute names and types
  - use `{ key1 = value1; key2 = value2; ... }` for adding attributes
    with known literals
  - end with an ellipsis (`...`) if the set can contain unknown
    attributes
  - use `{ [String] :: x }` if all the attributes has the same type `x`
- prefer `Any` over `a` if the latter is not reused
parent 64a8ada5
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ rec {
    # Type

    ```
    assertOneOf :: String -> ComparableVal -> List ComparableVal -> Bool
    assertOneOf :: String -> ComparableVal -> [ComparableVal] -> Bool
    ```

    # Examples
@@ -115,7 +115,7 @@ rec {
    # Type

    ```
    assertEachOneOf :: String -> List ComparableVal -> List ComparableVal -> Bool
    assertEachOneOf :: String -> [ComparableVal] -> [ComparableVal] -> Bool
    ```

    # Examples
@@ -164,7 +164,7 @@ rec {
    # Type

    ```
    checkAssertWarn :: [ { assertion :: Bool; message :: String } ] -> [ String ] -> Any -> Any
    checkAssertWarn :: [{ assertion :: Bool; message :: String; }] -> [String] -> a -> a
    ```

    # Examples
+25 −25
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ rec {
    # Type

    ```
    longestValidPathPrefix :: [String] -> Value -> [String]
    longestValidPathPrefix :: [String] -> AttrSet -> [String]
    ```

    # Examples
@@ -352,7 +352,7 @@ rec {
    # Type

    ```
    concatMapAttrs :: (String -> a -> AttrSet) -> AttrSet -> AttrSet
    concatMapAttrs :: (String -> Any -> AttrSet) -> AttrSet -> AttrSet
    ```

    # Examples
@@ -514,7 +514,7 @@ rec {
    # Type

    ```
    attrVals :: [String] -> AttrSet -> [Any]
    attrVals :: [String] -> { [String] :: a } -> [a]
    ```

    # Examples
@@ -537,7 +537,7 @@ rec {
    # Type

    ```
    attrValues :: AttrSet -> [Any]
    attrValues :: { [String] :: a } -> [a]
    ```

    # Examples
@@ -570,7 +570,7 @@ rec {
    # Type

    ```
    getAttrs :: [String] -> AttrSet -> AttrSet
    getAttrs :: [String] -> { [String] :: a } -> { [String] :: a }
    ```

    # Examples
@@ -603,7 +603,7 @@ rec {
    # Type

    ```
    catAttrs :: String -> [AttrSet] -> [Any]
    catAttrs :: String -> [{ [String] :: a }] -> [a]
    ```

    # Examples
@@ -646,7 +646,7 @@ rec {
    # Type

    ```
    filterAttrs :: (String -> Any -> Bool) -> AttrSet -> AttrSet
    filterAttrs :: (String -> a -> Bool) -> { [String] :: a } -> { [String] :: a }
    ```

    # Examples
@@ -737,7 +737,7 @@ rec {
    # Type

    ```
    foldlAttrs :: ( a -> String -> b -> a ) -> a -> { ... :: b } -> a
    foldlAttrs :: ( a -> String -> b -> a ) -> a -> { [String] :: b } -> a
    ```

    # Examples
@@ -812,7 +812,7 @@ rec {
    # Type

    ```
    foldAttrs :: (Any -> Any -> Any) -> Any -> [AttrSets] -> Any
    foldAttrs :: (a -> b -> b) -> b -> [{ [String] :: a }] -> { [String] :: b }
    ```

    # Examples
@@ -850,7 +850,7 @@ rec {
    # Type

    ```
    collect :: (AttrSet -> Bool) -> AttrSet -> [x]
    collect :: (AttrSet -> Bool) -> AttrSet -> [Any]
    ```

    # Examples
@@ -889,7 +889,7 @@ rec {
    # Type

    ```
    cartesianProduct :: AttrSet -> [AttrSet]
    cartesianProduct :: { [String] :: [a] } -> [{ [String] :: a }]
    ```

    # Examples
@@ -934,7 +934,7 @@ rec {
    # Type

    ```
    mapCartesianProduct :: (AttrSet -> a) -> AttrSet -> [a]
    mapCartesianProduct :: ({ [String] :: a } -> b) -> { [String] :: a } -> [b]
    ```

    # Examples
@@ -966,7 +966,7 @@ rec {
    # Type

    ```
    nameValuePair :: String -> Any -> { name :: String; value :: Any; }
    nameValuePair :: String -> a -> { name :: String; value :: a; }
    ```

    # Examples
@@ -998,7 +998,7 @@ rec {
    # Type

    ```
    mapAttrs :: (String -> Any -> Any) -> AttrSet -> AttrSet
    mapAttrs :: (String -> a -> b) -> { [String] :: a } -> { [String] :: b }
    ```

    # Examples
@@ -1033,7 +1033,7 @@ rec {
    # Type

    ```
    mapAttrs' :: (String -> Any -> { name :: String; value :: Any; }) -> AttrSet -> AttrSet
    mapAttrs' :: (String -> a -> { name :: String; value :: b; }) -> { [String] :: a } -> { [String] :: b }
    ```

    # Examples
@@ -1067,7 +1067,7 @@ rec {
    # Type

    ```
    mapAttrsToList :: (String -> a -> b) -> AttrSet -> [b]
    mapAttrsToList :: (String -> a -> b) -> { [String] :: a } -> [b]
    ```

    # Examples
@@ -1113,7 +1113,7 @@ rec {
    # Type

    ```
    attrsToList :: AttrSet -> [ { name :: String; value :: Any; } ]
    attrsToList :: { [String] :: a } -> [{ name :: String; value :: a; }]
    ```

    # Examples
@@ -1327,7 +1327,7 @@ rec {
    # Type

    ```
    genAttrs :: [ String ] -> (String -> Any) -> AttrSet
    genAttrs :: [String] -> (String -> a) -> { [String] :: a }
    ```

    # Examples
@@ -1364,7 +1364,7 @@ rec {
    # Type

    ```
    genAttrs' :: [ Any ] -> (Any -> { name :: String; value :: Any; }) -> AttrSet
    genAttrs' :: [a] -> (a -> { name :: String; value :: b; }) -> { [String] :: b }
    ```

    # Examples
@@ -1498,7 +1498,7 @@ rec {
    # Type

    ```
    zipAttrsWithNames :: [ String ] -> (String -> [ Any ] -> Any) -> [ AttrSet ] -> AttrSet
    zipAttrsWithNames :: [String] -> (String -> [a] -> b) -> [{ [String] :: a }] -> { [String] :: b }
    ```

    # Examples
@@ -1533,7 +1533,7 @@ rec {
    # Type

    ```
    zipAttrsWith :: (String -> [ Any ] -> Any) -> [ AttrSet ] -> AttrSet
    zipAttrsWith :: (String -> [a] -> b) -> [{ [String] :: a }] -> { [String] :: b }
    ```

    # Examples
@@ -1558,7 +1558,7 @@ rec {
    # Type

    ```
    zipAttrs :: [ AttrSet ] -> AttrSet
    zipAttrs :: [{ [String] :: a }] -> { [String] :: [a] }
    ```

    # Examples
@@ -1589,7 +1589,7 @@ rec {
    # Type

    ```
    mergeAttrsList :: [ Attrs ] -> Attrs
    mergeAttrsList :: [AttrSet] -> AttrSet
    ```

    # Examples
@@ -1609,7 +1609,7 @@ rec {
    list:
    let
      # `binaryMerge start end` merges the elements at indices `index` of `list` such that `start <= index < end`
      # Type: Int -> Int -> Attrs
      # Type: Int -> Int -> AttrSet
      binaryMerge =
        start: end:
        # assert start < end; # Invariant
+35 −22
Original line number Diff line number Diff line
@@ -626,7 +626,7 @@ rec {
    # Type

    ```
    makeScope :: (AttrSet -> ((AttrSet -> a) | Path) -> AttrSet -> a) -> (AttrSet -> AttrSet) -> scope
    makeScope :: (AttrSet -> ((AttrSet -> a) | Path) -> AttrSet -> a) -> (AttrSet -> AttrSet) -> Scope
    ```
  */
  makeScope =
@@ -689,19 +689,19 @@ rec {

    ```
    makeScopeWithSplicing' ::
      { splicePackages :: Splice -> AttrSet
      , newScope :: AttrSet -> ((AttrSet -> a) | Path) -> AttrSet -> a
      { splicePackages :: Splice -> AttrSet;
        newScope :: AttrSet -> ((AttrSet -> a) | Path) -> AttrSet -> a;
      }
      -> { otherSplices :: Splice, keep :: AttrSet -> AttrSet, extra :: AttrSet -> AttrSet }
      -> { otherSplices :: Splice; keep :: AttrSet -> AttrSet; extra :: AttrSet -> AttrSet; }
      -> AttrSet

    Splice ::
      { pkgsBuildBuild :: AttrSet
      , pkgsBuildHost :: AttrSet
      , pkgsBuildTarget :: AttrSet
      , pkgsHostHost :: AttrSet
      , pkgsHostTarget :: AttrSet
      , pkgsTargetTarget :: AttrSet
    Splice :: {
      pkgsBuildBuild :: AttrSet;
      pkgsBuildHost :: AttrSet;
      pkgsBuildTarget :: AttrSet;
      pkgsHostHost :: AttrSet;
      pkgsHostTarget :: AttrSet;
      pkgsTargetTarget :: AttrSet;
    }
    ```
  */
@@ -806,17 +806,16 @@ rec {
    ```
    extendMkDerivation ::
      {
        constructDrv :: ((FixedPointArgs | AttrSet) -> a)
        excludeDrvArgNames :: [ String ],
        excludeFunctionArgNames :: [ String ]
        extendDrvArgs :: (AttrSet -> AttrSet -> AttrSet)
        inheritFunctionArgs :: Bool,
        transformDrv :: a -> a,
        constructDrv :: (FixedPointArgs | AttrSet) -> Derivation;
        excludeDrvArgNames :: [String];
        excludeFunctionArgNames :: [String];
        extendDrvArgs :: AttrSet -> AttrSet -> AttrSet;
        inheritFunctionArgs :: Bool;
        transformDrv :: Derivation -> Derivation;
      }
      -> (FixedPointArgs | AttrSet) -> a
      -> ((FixedPointArgs | AttrSet) -> Derivation)

    FixedPointArgs = AttrSet -> AttrSet
    a = Derivation when defining a build helper
    FixedPointArgs :: AttrSet -> AttrSet
    ```

    # Examples
@@ -998,7 +997,21 @@ rec {
    # Type

    ```
    mapCrossIndex :: (a -> b) -> AttrSet -> AttrSet
    mapCrossIndex :: (a -> b) -> {
      buildBuild :: a;
      buildHost :: a;
      buildTarget :: a;
      hostHost :: a;
      hostTarget :: a;
      targetTarget :: a;
    } -> {
      buildBuild :: b;
      buildHost :: b;
      buildTarget :: b;
      hostHost :: b;
      hostTarget :: b;
      targetTarget :: b;
    }
    ```

    # Examples
+6 −6
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ rec {
    # Type

    ```
    traceIf :: bool -> string -> a -> a
    traceIf :: Bool -> String -> a -> a
    ```

    # Examples
@@ -327,7 +327,7 @@ rec {
    # Type

    ```
    traceValSeqNFn :: (a -> b) -> int -> a -> a
    traceValSeqNFn :: (a -> b) -> Int -> a -> a
    ```

    # Examples
@@ -362,7 +362,7 @@ rec {
    # Type

    ```
    traceValSeqN :: int -> a -> a
    traceValSeqN :: Int -> a -> a
    ```

    # Examples
@@ -407,7 +407,7 @@ rec {
    # Type

    ```
    traceFnSeqN :: int -> string -> (a -> b) -> a -> b
    traceFnSeqN :: Int -> String -> (a -> b) -> a -> b
    ```

    # Examples
@@ -466,7 +466,7 @@ rec {

    ```
    runTests :: {
      tests = [ String ];
      tests :: [String];
      ${testName} :: {
        expr :: a;
        expected :: a;
@@ -566,7 +566,7 @@ rec {
      ];
    }
    ->
    null
    Null
    ```

    # Examples
+2 −2
Original line number Diff line number Diff line
@@ -195,7 +195,7 @@ in
    # Type

    ```
    optionalDrvAttr :: Bool -> a -> a | Null
    optionalDrvAttr :: Bool -> a -> (a | Null)
    ```

    # Examples
@@ -236,7 +236,7 @@ in
    # Type

    ```
    warnOnInstantiate :: string -> Derivation -> Derivation
    warnOnInstantiate :: String -> Derivation -> Derivation
    ```

    # Examples
Loading