diff options
author | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-09-26 02:10:46 +0200 |
---|---|---|
committer | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-10-11 16:17:48 +0200 |
commit | 4ecf0258149f4e197e9dea4d71ab22756ffc5ece (patch) | |
tree | cd19db00d816693b2c2758093eb3b7db98380ad9 /lib/fileset/README.md | |
parent | 2541635c1377528f7503f65537fbf96d96aa9d22 (diff) | |
download | nixpkgs-4ecf0258149f4e197e9dea4d71ab22756ffc5ece.tar nixpkgs-4ecf0258149f4e197e9dea4d71ab22756ffc5ece.tar.gz nixpkgs-4ecf0258149f4e197e9dea4d71ab22756ffc5ece.tar.bz2 nixpkgs-4ecf0258149f4e197e9dea4d71ab22756ffc5ece.tar.lz nixpkgs-4ecf0258149f4e197e9dea4d71ab22756ffc5ece.tar.xz nixpkgs-4ecf0258149f4e197e9dea4d71ab22756ffc5ece.tar.zst nixpkgs-4ecf0258149f4e197e9dea4d71ab22756ffc5ece.zip |
lib.fileset.intersection: init
Diffstat (limited to 'lib/fileset/README.md')
-rw-r--r-- | lib/fileset/README.md | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/lib/fileset/README.md b/lib/fileset/README.md index 1aed7efec4c..393cafb42e3 100644 --- a/lib/fileset/README.md +++ b/lib/fileset/README.md @@ -143,6 +143,33 @@ Arguments: - (-) Leaves us with no identity element for `union` and no reasonable return value for `unions []`. From a set theory perspective, which has a well-known notion of empty sets, this is unintuitive. +### No intersection for lists + +While there is `intersection a b`, there is no function `intersections [ a b c ]`. + +Arguments: +- (+) There is no known use case for such a function, it can be added later if a use case arises +- (+) There is no suitable return value for `intersections [ ]`, see also "Nullary intersections" [here](https://en.wikipedia.org/w/index.php?title=List_of_set_identities_and_relations&oldid=1177174035#Definitions) + - (-) Could throw an error for that case + - (-) Create a special value to represent "all the files" and return that + - (+) Such a value could then not be used with `fileFilter` unless the internal representation is changed considerably + - (-) Could return the empty file set + - (+) This would be wrong in set theory +- (-) Inconsistent with `union` and `unions` + +### Intersection base path + +The base path of the result of an `intersection` is the longest base path of the arguments. +E.g. the base path of `intersection ./foo ./foo/bar` is `./foo/bar`. +Meanwhile `intersection ./foo ./bar` returns the empty file set without a base path. + +Arguments: +- Alternative: Use the common prefix of all base paths as the resulting base path + - (-) This is unnecessarily strict, because the purpose of the base path is to track the directory under which files _could_ be in the file set. It should be as long as possible. + All files contained in `intersection ./foo ./foo/bar` will be under `./foo/bar` (never just under `./foo`), and `intersection ./foo ./bar` will never contain any files (never under `./.`). + This would lead to `toSource` having to unexpectedly throw errors for cases such as `toSource { root = ./foo; fileset = intersect ./foo base; }`, where `base` may be `./bar` or `./.`. + - (-) There is no benefit to the user, since base path is not directly exposed in the interface + ### Empty directories File sets can only represent a _set_ of local files, directories on their own are not representable. @@ -161,7 +188,7 @@ Arguments: - `./.` represents all files in `./.` _and_ the directory itself, but not its subdirectories, meaning that at least `./.` will be preserved even if it's empty. - In that case, `intersect ./. ./foo` should only include files and no directories themselves, since `./.` includes only `./.` as a directory, and same for `./foo`, so there's no overlap in directories. + In that case, `intersection ./. ./foo` should only include files and no directories themselves, since `./.` includes only `./.` as a directory, and same for `./foo`, so there's no overlap in directories. But intuitively this operation should result in the same as `./foo` – everything else is just confusing. - (+) This matches how Git only supports files, so developers should already be used to it. - (-) Empty directories (even if they contain nested directories) are neither representable nor preserved when coercing from paths. |