query
On this page

difference

lib.fileset.difference

Docs pulled from | This Revision | 10 minutes ago


The file set containing all files from the first file set that are not in the second file set. See also Difference (set theory).

The given file sets are evaluated as lazily as possible, with the first argument being evaluated first if needed.

Inputs

positive

The positive file set. The result can only contain files that are also in this file set. This argument can also be a path, which gets implicitly coerced to a file set.

negative

The negative file set. The result will never contain files that are also in this file set. This argument can also be a path, which gets implicitly coerced to a file set.

Type

union :: FileSet -> FileSet -> FileSet

Examples

lib.fileset.difference usage example

# Create a file set containing all files from the current directory,
# except ones under ./tests
difference ./. ./tests

let
  # A set of Nix-related files
  nixFiles = unions [ ./default.nix ./nix ./tests/default.nix ];
in
# Create a file set containing all files under ./tests, except ones in `nixFiles`,
# meaning only without ./tests/default.nix
difference ./tests nixFiles

Noogle detected

Implementation

The following is the current implementation of this function.

difference =
    positive: negative:
    let
      filesets = _coerceMany "lib.fileset.difference" [
        {
          context = "First argument (positive set)";
          value = positive;
        }
        {
          context = "Second argument (negative set)";
          value = negative;
        }
      ];
    in
    _difference (elemAt filesets 0) (elemAt filesets 1);