Builtins: add builtins.concatMap

Fixes #448
This commit is contained in:
Félix Baylac-Jacqué 2019-03-31 18:51:37 +02:00 committed by John Wiegley
parent 3acc67ba66
commit cacbfdbd6d
2 changed files with 15 additions and 1 deletions

View File

@ -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 ->

View File

@ -70,7 +70,6 @@ newFailingTests = Set.fromList
[ "eval-okay-path"
, "eval-okay-fromTOML"
, "eval-okay-context-introspection"
, "eval-okay-concatmap"
]
genTests :: IO TestTree