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: compose
and pipe
functions
#38422
Conversation
Provide base functions for function composition.
pkgs/servers/x11/xorg/overrides.nix
Outdated
@@ -3,7 +3,7 @@ | |||
let | |||
inherit (args) stdenv makeWrapper; | |||
inherit (stdenv) lib isDarwin; | |||
inherit (lib) overrideDerivation; | |||
inherit (lib) overrideDerivation compose; |
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.
where is this method used here?
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.
Hmmm... you're right - it doesn't looks like that expression was actually in use there. I'll drop the inherit.
Not really in favor of this. Expressions like |
I'm still super green to Nix, so apologies for any lack of knowledge when it comes to perf characteristics - is there a reason for that suggested slowness in the implementation of As for readability, I prefer pointfree (which these enable). The lack of an infix pipe [ a b c d ] vs x: d (c (b (a x))) It comes down to stylistic preferences. Happy to keep it in my personal libs if it doesn't mesh with the style used through the rest of the repo. |
Entirely coincidentally I spent an hour or so yesterday looking for a |
I have a definition of this too, with comment saying along the lines of "surely it exists already and but I'm blind so here we go"... Haha. Are these named similarly elsewhere? Consistently? If so helps a bit with reading. If perf is bad maybe it should just be a builtin! :P |
Happy to split these out if they're easier to consider in isolation. Definitely agree that builtins would be optimal. If going that route, extending to |
What is the status of this pull request? |
@edolstra expressed some valid performance concerns with I've just had a grep through the current repo state and could find another implementation of Let me know which way you'd like to go and I can either drop this down to just compose, or close this off without the merge. |
In my opinion neither of this is useful unless it's defined as a infix or used in laguage where it's possible to write binary functions as infix (like haskells ``` syntax). |
Let's close this for now. |
Provide base functions for function composition.
Motivation for this change
Just a couple of low level primitives that are likely useful across various modules / packages.
Rather than implementing these everywhere they're needed, it probably makes sense to include them here. I had a quick grep through the repo and could only find a single current implementation, which I've redirected back to this.
Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)