I’m getting this error when using the crossLists function, but it’s not clear how cartesianProductOfSets is a replacement. Is this deprecation message correct?
@Infinisil sorry to bother 3 years later , but given your suggestion there, do you recall if this use case was considered? It seems the original scenario was quite different than mine.
There’s a change in that PR that represents my use case actually, and the answer seems to be use map + cartesianProductOfSets as opposed to just the latter.
I can submit a PR to fix the deprecated message if this is the intention, but wondering can we still have a non-deprecated lib.lists.crossLists function implemented on top of those two functions?
When using mapCartesianProduct as a replacement for crossLists it looks like the order of results you get is now alphabetically sorted. crossLists maintained an order based on the order of the input lists.
If you used crossLists to generate something where the order mattered like a list in the config of a UI it seems like the best alternative right now is to inline the deprecated definition to avoid the warning.
Ah, so the sense in which it sorts is that it cares about the lexicographic order of the keys picked, so you can match the behavior of crossLists by adjusting those:
That’s not related to the function, that’s just how sets work in nix. Order of keys is not going to follow the order that you specified, they are essentially sorted.
nix-repl> { a = 7; _b = 8; }
{
_b = 8;
a = 7;
}
Though I understand the resulting behavior here can be confusing.
It’s related in the sense that the API taking a set in requires you to pick names and they matter, encouraging you to pick arbitrary names that are alphabetically ordered instead of using meaningful names, while before if you’re using crossLists you can use meaningful names for the inputs to the function you pass to it without needing to fudge them to get your desired output order.
Would it make sense to remove the deprecation warning from crossLists since using mapCartesianProduct + arbitrary names to get the desired order feels kinda kludgy?