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: Add composeExtensions for composing extension functions #24716
Conversation
@shlevy, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @peti and @Profpatsch to be potential reviewers. |
I'm pretty sure this is right and my tests pass, but just wanted a second opinion. |
Nope, it's wrong, fix incoming |
6356288
to
0a15af2
Compare
OK, should be working now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These modification sounds correct.
I also agree with @Profpatsch that we should be adding tests to our lib functions now (see lib/tests
directory).
OK, I'll add some tests |
For function tests, |
Hah I just recently wrote this not knowing it was added. It took me a couple attempts, but then I fixed it by proving the monoid https://gist.github.com/Ericson2314/ab120ccce04ac41b2ec2bec11fda3879 . I'm not sure which of machine-checked tests or hand-written proof is better for inclusion in Nixpkgs, but rest assured this PR is correct 😀 . |
@Ericson2314 There are tests already, but if you want to formalize nix in coq and check in a machine-checked proof I'm 💯 👅 |
Maybe it would be more practical to compose lists of extensions directly. We already use let # ...
toFix = lib.foldl' (lib.flip lib.extends) (self: {}) someListOfExtensions;
in lib.fix toFix |
@vcunat More practical in what sense? We've been using this as-is for a while now. |
Just a random thought. It surely depends on particular use case (and the number of extensions you usually combine). |
@vcunat on the contrary I rather do a fold1 with |
Yes, using folds explicitly would be a more idiomatic way, at least if we had a |
Well, while it's extra needless work, the monoid identity can always provide the base case for a normal fold too. |
No description provided.