-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
Decide on a recursive attribute set tree flattening function #237776
Comments
maybe we can start with |
Is that EDIT: 🤦 skimmed over |
It can be if you pass in a recursive merge function, is just a more generalized version of the
|
We have rather many possible combinations of recursion, filtering, mapping, and ways to recombine information into a single attribute name. Picking specific combinations of these strategies and giving a name to them isn't particularly helpful, especially if done in an ad hoc way (without much consideration for naming conventions that would effectively only serve to refer to those multiple strategies in ways that won't be as good as an actual programmatic decomposition of the problem). The Fairbairn threshold suggests that we wouldn't be making any progress towards making the library and programs more understandable that way (at best). I think the problem can be decomposed at the call site, taking the following shape: someTraversal
maybeSomeParameter
(callbackParams:
{
${attributeName} = callbackParams.value;
}) Now this pattern doesn't look great, but it does convey all the information in a systematic manner, and unlike an semi-incoherent set of names, this is more like a useful skill that I believe is easy to learn, and can be taught (e.g. in the docs) with a few examples. What are the choices for each strategy?
Note: we may want to change
Example: in the context of flakes, convert concatMapAttrsRecursiveUntil (_path: isDerivation) (attrPath: value: {
${concatStringsSep "." attrPath} = value;
}) Would So I think a function like I'd happily accept a tl;dr: start with (btw the Related: |
My personal liking is towards "collect" I think the Initial implementation of collect wasnt generic enough. All of the linked PRs can be acheived using collect' from one of the PRs and sometimes wrapping it with listToAttrs. i think the Interface is good and Kind of Matches your Idea. I dislike that overly precise name (concatMapAttrsRecursiveUntil) because its to long and hard to type. I will try and collect all functions from those categories and see how to apply intuitive names for them. maybe we can also find a way that avoids creating an intermediate list for performance reasons. |
I agree. Was trying to stick with the naming system, but that may not be necessary.
Achievable with
|
Transforming the leaves of a tree is not a particularly "recursive" computation from a user perspective. |
Project description
All of the PRs below try to add a function that recurses into a tree of attrsets.
Clearly there's a need. What needs to be done is decide on the name and behavior of the function.
The name should fit the established naming conventions. The behavior should probably be biased towards keeping it simple and "composable".
Some discussion seems necessary, hence a new thread in this issue to discuss the new function's details.
lib
: Working with nested attrsets of packages #202517flattenAttrs
function #354874Metadata
./lib
The text was updated successfully, but these errors were encountered: