From c01f657e8d46f213ac5906924ff37013275830e3 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 26 Oct 2023 19:36:32 +0100 Subject: [PATCH] lib: lists: add 'nullableToList' --- lib/lists.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/lists.nix b/lib/lists.nix index 190198e..6c2fadd 100644 --- a/lib/lists.nix +++ b/lib/lists.nix @@ -24,4 +24,10 @@ in # (any -> value) # [ any ] mapFilter = pred: f: attrs: filter pred (map f attrs); + + # Transform a nullable value into a list of zero/one element. + # + # nullableToList :: + # (nullable a) -> [ a ] + nullableToList = x: if x != null then [ x ] else [ ]; }