query
On this page

unions

lib.fileset.unions

Docs pulled from | This Revision | 10 minutes ago


The file set containing all files that are in any of the given file sets. This is the same as union, but takes a list of file sets instead of just two. See also Union (set theory).

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

Inputs

filesets

A list of file sets. The elements can also be paths, which get implicitly coerced to file sets.

Type

unions :: [ FileSet ] -> FileSet

Examples

lib.fileset.unions usage example

# Create a file set containing selected files
unions [
  # Include the single file `Makefile` in the current directory
  # This errors if the file doesn't exist
  ./Makefile

  # Recursively include all files in the `src/code` directory
  # If this directory is empty this has no effect
  ./src/code

  # Include the files `run.sh` and `unit.c` from the `tests` directory
  ./tests/run.sh
  ./tests/unit.c

  # Include the `LICENSE` file from the parent directory
  ../LICENSE
]

Noogle detected

Implementation

The following is the current implementation of this function.

unions =
    filesets:
    if !isList filesets then
      throw ''lib.fileset.unions: Argument is of type ${typeOf filesets}, but it should be a list instead.''
    else
      pipe filesets [
        # Annotate the elements with context, used by _coerceMany for better errors
        (imap0 (
          i: el: {
            context = "Element ${toString i}";
            value = el;
          }
        ))
        (_coerceMany "lib.fileset.unions")
        _unionMany
      ];