Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib.fileset: Implicitly coerce lists to unions #267387

Open
infinisil opened this issue Nov 14, 2023 · 1 comment
Open

lib.fileset: Implicitly coerce lists to unions #267387

infinisil opened this issue Nov 14, 2023 · 1 comment
Labels
5. scope: tracked Issue (or PR) is linked back to a `5. scope: tracking` issue

Comments

@infinisil
Copy link
Member

For all lib.fileset functions taking file sets as arguments, it would be possible to implicitly coerce list types to the union of their elements. So e.g.

let
  fs = lib.fileset;
in
fs.toSource {
  root = ./.;
  fileset = fs.difference
    (fs.unions [
      ./Makefile
      ./src
    ])
    (fs.unions [
      ./src/tests
      ./src/main.o
    ]);
}

could be shortened to

let
  fs = lib.fileset;
in
fs.toSource {
  root = ./.;
  fileset = fs.difference
    [
      ./Makefile
      ./src
    ]
    [
      ./src/tests
      ./src/main.o
    ];
}

I did think of this while developing the library, but held back because I wasn't sure about the implications, especially regarding the duality of union and intersection.

But now that we decided against having a list version of intersection, it has become pretty clear that union is the one and only operation that would make sense to use by default for lists.

@alyssais would probably like this.

This issue is sponsored by Antithesis

@infinisil
Copy link
Member Author

Oh and if we have this, we probably don't need lib.fileset.empty then, because [ ] is empty!

@samueldr samueldr added the 5. scope: tracked Issue (or PR) is linked back to a `5. scope: tracking` issue label Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5. scope: tracked Issue (or PR) is linked back to a `5. scope: tracking` issue
Projects
None yet
Development

No branches or pull requests

2 participants