Skip to content

Commit 0071387

Browse files
committed
Convert: add traverseToValue
1 parent 65c9137 commit 0071387

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Nix/Convert.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ traverseFromM
8080
-> m (Maybe (t b))
8181
traverseFromM = traverseM fromValueMay
8282

83+
traverseToValue :: ((Traversable t, Applicative f, ToValue a f b) => t a -> f (t b))
84+
traverseToValue = traverse toValue
85+
8386
-- Please, hide these helper function from export, to be sure they get optimized away.
8487
fromMayToValue
8588
:: forall t f m a e
@@ -423,7 +426,7 @@ instance (Convertible e t f m
423426
, ToValue a m (NValue t f m)
424427
)
425428
=> ToValue [a] m (Deeper (NValue' t f m (NValue t f m))) where
426-
toValue l = Deeper . nvList' <$> traverse toValue l
429+
toValue l = Deeper . nvList' <$> traverseToValue l
427430

428431
instance Convertible e t f m
429432
=> ToValue (AttrSet (NValue t f m)) m (NValue' t f m (NValue t f m)) where
@@ -433,7 +436,7 @@ instance (Convertible e t f m, ToValue a m (NValue t f m))
433436
=> ToValue (AttrSet a) m (Deeper (NValue' t f m (NValue t f m))) where
434437
toValue s =
435438
liftA2 (\ v s -> Deeper $ nvSet' s v)
436-
(traverse toValue s)
439+
(traverseToValue s)
437440
stub
438441

439442
instance Convertible e t f m
@@ -446,7 +449,7 @@ instance (Convertible e t f m, ToValue a m (NValue t f m))
446449
(Deeper (NValue' t f m (NValue t f m))) where
447450
toValue (s, p) =
448451
liftA2 (\ v s -> Deeper $ nvSet' s v)
449-
(traverse toValue s)
452+
(traverseToValue s)
450453
(pure p)
451454

452455
instance Convertible e t f m
@@ -464,7 +467,7 @@ instance Convertible e t f m
464467
let
465468
outputs = mkNixStringWithoutContext <$> nlcvOutputs nlcv
466469

467-
ts :: [NValue t f m] <- traverse toValue outputs
470+
ts :: [NValue t f m] <- traverseToValue outputs
468471
list
469472
(pure Nothing)
470473
(fmap pure . toValue)

0 commit comments

Comments
 (0)