From f57e6f47d0f882ec29389a0699feb5f1f7db172c Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Thu, 18 Dec 2025 11:22:23 +1000 Subject: [PATCH] minor: std --- nib/std/attrs.nix | 17 +++++++++-------- nib/std/lists.nix | 2 ++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/nib/std/attrs.nix b/nib/std/attrs.nix index fa6fdd9..3d49ff9 100644 --- a/nib/std/attrs.nix +++ b/nib/std/attrs.nix @@ -93,16 +93,17 @@ in rec { mapAttrsRecursive = f: set: mapAttrsRecursiveCond (as: true) f set; - # form: attrValueAt :: xs -> path -> value + # form: attrValueAt :: list string -> set -> Maybe Any # given path as a list of strings, return that value of an # attribute set at that path - attrValueAt = let - value = foldl (l: r: - if builtins.isAttrs l && builtins.hasAttr r l - then l.${r} - else null); - in - nullableToMaybe value; + attrValueAt = path: xs: + foldl (left: right: + if builtins.isAttrs left && builtins.hasAttr right left + then left.${right} + else null) + xs + path + |> nullableToMaybe; mergeAttrsList = list: let # `binaryMerge start end` merges the elements at indices `index` of `list` such that `start <= index < end` diff --git a/nib/std/lists.nix b/nib/std/lists.nix index a8e9ff3..868bc3e 100644 --- a/nib/std/lists.nix +++ b/nib/std/lists.nix @@ -51,4 +51,6 @@ if index == null then default else builtins.elemAt list index; + + zipLists = zipListsWith (fst: snd: {inherit fst snd;}); }