Skip to content

Commit

Permalink
Convert: add traverseToValue
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton-Latukha committed Aug 21, 2021
1 parent 65c9137 commit 0071387
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Nix/Convert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ traverseFromM
-> m (Maybe (t b))
traverseFromM = traverseM fromValueMay

traverseToValue :: ((Traversable t, Applicative f, ToValue a f b) => t a -> f (t b))
traverseToValue = traverse toValue

-- Please, hide these helper function from export, to be sure they get optimized away.
fromMayToValue
:: forall t f m a e
Expand Down Expand Up @@ -423,7 +426,7 @@ instance (Convertible e t f m
, ToValue a m (NValue t f m)
)
=> ToValue [a] m (Deeper (NValue' t f m (NValue t f m))) where
toValue l = Deeper . nvList' <$> traverse toValue l
toValue l = Deeper . nvList' <$> traverseToValue l

instance Convertible e t f m
=> ToValue (AttrSet (NValue t f m)) m (NValue' t f m (NValue t f m)) where
Expand All @@ -433,7 +436,7 @@ instance (Convertible e t f m, ToValue a m (NValue t f m))
=> ToValue (AttrSet a) m (Deeper (NValue' t f m (NValue t f m))) where
toValue s =
liftA2 (\ v s -> Deeper $ nvSet' s v)
(traverse toValue s)
(traverseToValue s)
stub

instance Convertible e t f m
Expand All @@ -446,7 +449,7 @@ instance (Convertible e t f m, ToValue a m (NValue t f m))
(Deeper (NValue' t f m (NValue t f m))) where
toValue (s, p) =
liftA2 (\ v s -> Deeper $ nvSet' s v)
(traverse toValue s)
(traverseToValue s)
(pure p)

instance Convertible e t f m
Expand All @@ -464,7 +467,7 @@ instance Convertible e t f m
let
outputs = mkNixStringWithoutContext <$> nlcvOutputs nlcv

ts :: [NValue t f m] <- traverse toValue outputs
ts :: [NValue t f m] <- traverseToValue outputs
list
(pure Nothing)
(fmap pure . toValue)
Expand Down

0 comments on commit 0071387

Please sign in to comment.