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

lib: add type signature to some of the functions

parent 66221757
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ rec {
    # Type

    ```
    attrsets.longestValidPathPrefix :: [String] -> Value -> [String]
    longestValidPathPrefix :: [String] -> Value -> [String]
    ```

    # Examples
+79 −2
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ rec {

    ```nix
    trace { a.b.c = 3; } null
    trace: { a = <CODE>; }
    trace: { a = <thunk>; }
    => null
    traceSeq { a.b.c = 3; } null
    trace: { a = { b = { c = 3; }; }; }
@@ -257,6 +257,23 @@ rec {
    `v`

    : Value to trace

    # Type

    ```
    traceValSeqFn :: (a -> b) -> a -> a
    ```

    # Examples
    :::{.example}
    ## `lib.debug.traceValSeqFn` usage example

    ```nix
    traceValSeqFn (v: v // { d = "foo";}) { a.b.c = 3; }
    trace: { a = { b = { c = 3; }; }; d = "foo"; }
    => { a = { ... }; }

    :::
  */
  traceValSeqFn = f: v: traceValFn f (builtins.deepSeq v v);

@@ -268,6 +285,24 @@ rec {
    `v`

    : Value to trace

    # Type

    ```
    traceValSeq :: a -> a
    ```

    # Examples
    :::{.example}
    ## `lib.debug.traceValSeq` usage example

    ```nix
    traceValSeq { a.b.c = 3; }
    trace: { a = { b = { c = 3; }; }; }
    => { a = { ... }; }
    ```

    :::
  */
  traceValSeq = traceValSeqFn id;

@@ -288,6 +323,24 @@ rec {
    `v`

    : Value to trace

    # Type

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

    # Examples
    :::{.example}
    ## `lib.debug.traceValSeqNFn` usage example

    ```nix
    traceValSeqNFn (v: v // { d = "foo";}) 2 { a.b.c = 3; }
    trace: { a = { b = {…}; }; d = "foo"; }
    => { a = { ... }; }
    ```

    :::
  */
  traceValSeqNFn =
    f: depth: v:
@@ -305,6 +358,24 @@ rec {
    `v`

    : Value to trace

    # Type

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

    # Examples
    :::{.example}
    ## `lib.debug.traceValSeqN` usage example

    ```nix
    traceValSeqN 2 { a.b.c = 3; }
    trace: { a = { b = {…}; }; }
    => { a = { ... }; }
    ```

    :::
  */
  traceValSeqN = traceValSeqNFn id;

@@ -333,6 +404,12 @@ rec {

    : 4\. Function argument

    # Type

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

    # Examples
    :::{.example}
    ## `lib.debug.traceFnSeqN` usage example
@@ -340,7 +417,7 @@ rec {
    ```nix
    traceFnSeqN 2 "id" (x: x) { a.b.c = 3; }
    trace: { fn = "id"; from = { a.b = {…}; }; to = { a.b = {…}; }; }
    => { a.b.c = 3; }
    => { a = { ... }; }
    ```

    :::
+6 −0
Original line number Diff line number Diff line
@@ -233,6 +233,12 @@ in
    `drv`
    : The derivation to wrap.

    # Type

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

    # Examples
    :::{.example}
    ## `lib.derivations.warnOnInstantiate` usage example
+16 −16
Original line number Diff line number Diff line
@@ -302,16 +302,6 @@ in
      - Other files are ignored, including symbolic links to directories and to regular `.nix`
        files; this is because nixlang code cannot distinguish the type of a link's target.

    # Type

    ```
    packagesFromDirectoryRecursive :: {
      callPackage :: Path -> {} -> a,
      newScope? :: AttrSet -> scope,
      directory :: Path,
    } -> AttrSet
    ```

    # Inputs

    `callPackage`
@@ -326,6 +316,16 @@ in
    `directory`
    : The directory to read package files from.

    # Type

    ```
    packagesFromDirectoryRecursive :: {
      callPackage :: Path -> {} -> a,
      newScope? :: AttrSet -> scope,
      directory :: Path,
    } -> AttrSet
    ```

    # Examples
    :::{.example}
    ## Basic use of `lib.packagesFromDirectoryRecursive`
@@ -450,12 +450,6 @@ in
  /**
    Append `/default.nix` if the passed path is a directory.

    # Type

    ```
    resolveDefaultNix :: (Path | String) -> (Path | String)
    ```

    # Inputs

    A single argument which can be a [path](https://nix.dev/manual/nix/stable/language/types#type-path) value or a string containing an absolute path.
@@ -466,6 +460,12 @@ in
    Furthermore, if the input is a string that ends with `/`, `default.nix` is appended to it.
    Otherwise, the input is returned unchanged.

    # Type

    ```
    resolveDefaultNix :: (Path | String) -> (Path | String)
    ```

    # Examples
    :::{.example}
    ## `lib.filesystem.resolveDefaultNix` usage example
+6 −0
Original line number Diff line number Diff line
@@ -108,6 +108,12 @@ rec {
    `f`

    : 1\. Function argument

    # Type

    ```
    fix' :: (a -> a) -> a
    ```
  */
  fix' =
    f:
Loading