diff --git a/src/Nix/Builtins.hs b/src/Nix/Builtins.hs index acd1444..5565872 100644 --- a/src/Nix/Builtins.hs +++ b/src/Nix/Builtins.hs @@ -175,6 +175,7 @@ builtinsList = sequence , add2 Normal "catAttrs" catAttrs , add2 Normal "compareVersions" compareVersions_ , add Normal "concatLists" concatLists + , add2 Normal "concatMap" concatMap_ , add' Normal "concatStringsSep" (arity2 principledIntercalateNixString) , add0 Normal "currentSystem" currentSystem , add0 Normal "currentTime" currentTime_ @@ -1162,6 +1163,20 @@ concatLists = >=> toValue . concat +concatMap_ + :: forall e t f m + . MonadNix e t f m + => NValue t f m + -> NValue t f m + -> m (NValue t f m) +concatMap_ f = + fromValue @[NValue t f m] + >=> traverse applyFunc + >=> toValue . concat + where + applyFunc :: NValue t f m -> m [NValue t f m] + applyFunc = (f `callFunc`) >=> fromValue + listToAttrs :: forall e t f m . MonadNix e t f m => NValue t f m -> m (NValue t f m) listToAttrs = fromValue @[NValue t f m] >=> \l -> diff --git a/tests/NixLanguageTests.hs b/tests/NixLanguageTests.hs index 0ac6144..c6af57d 100644 --- a/tests/NixLanguageTests.hs +++ b/tests/NixLanguageTests.hs @@ -70,7 +70,6 @@ newFailingTests = Set.fromList [ "eval-okay-path" , "eval-okay-fromTOML" , "eval-okay-context-introspection" - , "eval-okay-concatmap" ] genTests :: IO TestTree