rajivr has quit [Quit: Connection closed for inactivity]
Dotz0cat has joined #nix-lang
<__monty__>
I have two attrsets with the same attrNames. I want a list of the values in the second for which the corresponding value in the first is "true". Anything more elegant than `builtins.filter notNull (lib.mapAttrsToList (n: v: if first.n then v else null) second)`?
<infinisil>
__monty__: I think `filter` and `map` over the `attrNames` should work better
<__monty__>
I was rather hoping for a way to avoid the if-then-else with optional or something.
<infinisil>
You won't need that
<infinisil>
> set1 = { a = true; b = false; c = true; }
<__monty__>
infinisil: Ah, thanks. Didn't think of inverting my logic.
<infinisil>
:)
<__monty__>
> let set = { a = 1; }; bools = { set = true; }; in with bools; if set then "T" else "F"
<{^_^}>
value is a set while a Boolean was expected
<__monty__>
Why doesn't with shadow the set here?
<__monty__>
The way with works is really inconvenient rn : /
<__monty__>
With not shadowing is way more confusing than with shadowing imo. Even if the latter would cause infinite recursions.
<infinisil>
__monty__: Yeah I've been meaning to change that
<infinisil>
Currently all variable definitions in the bot are a top-level `let in`
<__monty__>
infinisil: This is not a bot problem though. It's a problem with nix the language. This behavior was a "fix" to enable overriding without introducing infinite recursion or something. But I don't like the behavior `with set; [ a b c ]` should get those value from set unless they're not defined there.
<infinisil>
Ah yeah, I think I agree
<infinisil>
Or, let's get rid of `with` :)
<sterni>
yeah with and rec { } sets are probably not that great of an idea
<sterni>
they have pretty similar issues actually
<__monty__>
Recursive sets are fine imo, as long as they close over their scope.
<sterni>
well replacing them with fix points could be nice though
<sterni>
but probably detremental to eval time
<__monty__>
I've had more trouble understanding fixpoints than most things tbh.
<__monty__>
Anyway, I rewrote the with stuff with lib.attrValues. Happens to be possible in this case but not exactly convenient.