@@ -71,6 +71,14 @@ class FromValue a m v where
71
71
fromValue :: v -> m a
72
72
fromValueMay :: v -> m (Maybe a )
73
73
74
+ traverseToMValue
75
+ :: ( Applicative m
76
+ , Traversable t
77
+ , FromValue b m a
78
+ )
79
+ => t a
80
+ -> m (Maybe (t b ))
81
+ traverseToMValue = traverseM fromValueMay
74
82
75
83
-- Please, hide these helper function from export, to be sure they get optimized away.
76
84
fromMayToValue
@@ -277,7 +285,7 @@ instance ( Convertible e t f m
277
285
=> FromValue [a ] m (Deeper (NValue' t f m (NValue t f m ))) where
278
286
fromValueMay =
279
287
\ case
280
- Deeper (NVList' l) -> sequenceA <$> traverse fromValueMay l
288
+ Deeper (NVList' l) -> traverseToMValue l
281
289
_ -> stub
282
290
283
291
@@ -301,7 +309,7 @@ instance ( Convertible e t f m
301
309
302
310
fromValueMay =
303
311
\ case
304
- Deeper (NVSet' _ s) -> sequenceA <$> traverse fromValueMay s
312
+ Deeper (NVSet' _ s) -> traverseToMValue s
305
313
_ -> stub
306
314
307
315
fromValue = fromMayToDeeperValue TSet
@@ -326,7 +334,7 @@ instance ( Convertible e t f m
326
334
327
335
fromValueMay =
328
336
\ case
329
- Deeper (NVSet' p s) -> fmap (, p) . sequenceA <$> traverse fromValueMay s
337
+ Deeper (NVSet' p s) -> (, p) <<$>> traverseToMValue s
330
338
_ -> stub
331
339
332
340
fromValue = fromMayToDeeperValue TSet
@@ -345,13 +353,15 @@ instance ( Convertible e t f m
345
353
class ToValue a m v where
346
354
toValue :: a -> m v
347
355
348
- instance (Convertible e t f m , ToValue a m (NValue' t f m (NValue t f m )))
356
+ instance (Convertible e t f m
357
+ , ToValue a m (NValue' t f m (NValue t f m ))
358
+ )
349
359
=> ToValue a m (NValue t f m ) where
350
360
toValue v = Free <$> toValue v
351
361
352
362
instance ( Convertible e t f m
353
- , ToValue a m (Deeper (NValue' t f m (NValue t f m )))
354
- )
363
+ , ToValue a m (Deeper (NValue' t f m (NValue t f m )))
364
+ )
355
365
=> ToValue a m (Deeper (NValue t f m )) where
356
366
toValue v = Free <<$>> toValue v
357
367
@@ -395,8 +405,7 @@ instance Convertible e t f m
395
405
=> ToValue StorePath m (NValue' t f m (NValue t f m )) where
396
406
toValue = toValue @ Path . coerce
397
407
398
- instance ( Convertible e t f m
399
- )
408
+ instance Convertible e t f m
400
409
=> ToValue SourcePos m (NValue' t f m (NValue t f m )) where
401
410
toValue (SourcePos f l c) = do
402
411
f' <- toValue $ mkNixStringWithoutContext $ fromString f
@@ -410,7 +419,9 @@ instance Convertible e t f m
410
419
=> ToValue [NValue t f m ] m (NValue' t f m (NValue t f m )) where
411
420
toValue = pure . nvList'
412
421
413
- instance (Convertible e t f m , ToValue a m (NValue t f m ))
422
+ instance (Convertible e t f m
423
+ , ToValue a m (NValue t f m )
424
+ )
414
425
=> ToValue [a ] m (Deeper (NValue' t f m (NValue t f m ))) where
415
426
toValue l = Deeper . nvList' <$> traverse toValue l
416
427
0 commit comments