@@ -360,7 +360,7 @@ foldNixPath f z = do
360360 dirs <-
361361 maybe
362362 (pure mempty )
363- (demand (fromValue . Deeper ))
363+ (demandF (fromValue . Deeper ))
364364 mres
365365 mPath <- getEnvVar " NIX_PATH"
366366 mDataDir <- getEnvVar " NIX_DATA_DIR"
@@ -449,9 +449,9 @@ unsafeGetAttrPos
449449 -> NValue t f m
450450 -> m (NValue t f m )
451451unsafeGetAttrPos x y =
452- demand
452+ demandF
453453 (\ x' ->
454- demand
454+ demandF
455455 (\ y' -> case (x', y') of
456456 (NVStr ns, NVSet _ apos) ->
457457 maybe
476476 -> NValue t f m
477477 -> m (NValue t f m )
478478add_ x y =
479- demand
479+ demandF
480480 (\ x' ->
481- demand
481+ demandF
482482 (\ y' ->
483483 case (x', y') of
484484 (NVConstant (NInt x), NVConstant (NInt y)) -> toValue (x + y :: Integer )
497497 -> NValue t f m
498498 -> m (NValue t f m )
499499mul_ x y =
500- demand
500+ demandF
501501 (\ x' ->
502- demand
502+ demandF
503503 (\ y' ->
504504 case (x', y') of
505505 (NVConstant (NInt x), NVConstant (NInt y) ) -> toValue (x * y :: Integer )
518518 -> NValue t f m
519519 -> m (NValue t f m )
520520div_ x y =
521- demand
521+ demandF
522522 (\ x' ->
523- demand
523+ demandF
524524 (\ y' ->
525525 case (x', y') of
526526 (NVConstant (NInt x), NVConstant (NInt y)) | y /= 0 -> toValue $ (floor (fromInteger x / fromInteger y :: Double ) :: Integer )
@@ -895,7 +895,7 @@ catAttrs attrName xs =
895895
896896 fmap (nvList . catMaybes) $
897897 forM l $
898- fmap (M. lookup n) . demand fromValue
898+ fmap (M. lookup n) . demandF fromValue
899899
900900baseNameOf :: MonadNix e t f m => NValue t f m -> m (NValue t f m )
901901baseNameOf x = do
@@ -950,7 +950,7 @@ builtinsBuiltin = throwError $ ErrorCall "HNix does not provide builtins.builtin
950950
951951dirOf :: MonadNix e t f m => NValue t f m -> m (NValue t f m )
952952dirOf =
953- demand
953+ demandF
954954 (\ case
955955 NVStr ns -> pure $ nvStr $ modifyNixContents (Text. pack . takeDirectory . Text. unpack) ns
956956 NVPath path -> pure $ nvPath $ takeDirectory path
969969 => NValue t f m
970970 -> NValue t f m
971971 -> m (NValue t f m )
972- seq_ a b = demand (const $ pure b) a
972+ seq_ a b = demandF (const $ pure b) a
973973
974974-- | We evaluate 'a' only for its effects, so data cycles are ignored.
975975deepSeq
@@ -1057,10 +1057,10 @@ genericClosure = fromValue @(AttrSet (NValue t f m)) >=> \s ->
10571057 (Nothing , Just _ ) -> throwError $ ErrorCall " builtins.genericClosure: Attribute 'startSet' required"
10581058 (Just _ , Nothing ) -> throwError $ ErrorCall " builtins.genericClosure: Attribute 'operator' required"
10591059 (Just startSet, Just operator) ->
1060- demand
1060+ demandF
10611061 (fromValue @ [NValue t f m ] >=>
10621062 (\ ss ->
1063- demand
1063+ demandF
10641064 (\ op -> toValue @ [NValue t f m ] =<< snd <$> go op S. empty ss)
10651065 operator
10661066 )
@@ -1074,12 +1074,12 @@ genericClosure = fromValue @(AttrSet (NValue t f m)) >=> \s ->
10741074 -> m (Set (WValue t f m ), [NValue t f m ])
10751075 go _ ks [] = pure (ks, mempty )
10761076 go op ks (t : ts) =
1077- demand
1077+ demandF
10781078 (\ v ->
10791079 (do
10801080 s <- fromValue @ (AttrSet (NValue t f m )) v
10811081 k <- attrsetGet " key" s
1082- demand
1082+ demandF
10831083 (\ k' -> do
10841084 bool
10851085 (do
@@ -1221,7 +1221,7 @@ intersectAttrs set1 set2 =
12211221functionArgs
12221222 :: forall e t f m . MonadNix e t f m => NValue t f m -> m (NValue t f m )
12231223functionArgs fun =
1224- demand
1224+ demandF
12251225 (\ case
12261226 NVClosure p _ ->
12271227 toValue @ (AttrSet (NValue t f m )) $ nvConstant . NBool <$>
@@ -1251,7 +1251,7 @@ toPath = fromValue @Path >=> toValue @Path
12511251
12521252pathExists_ :: MonadNix e t f m => NValue t f m -> m (NValue t f m )
12531253pathExists_ =
1254- demand
1254+ demandF
12551255 (
12561256 \ case
12571257 NVPath p -> toValue =<< pathExists p
@@ -1295,15 +1295,15 @@ isNull = hasKind @()
12951295-- isString cannot use `hasKind` because it coerces derivations to strings.
12961296isString :: MonadNix e t f m => NValue t f m -> m (NValue t f m )
12971297isString =
1298- demand
1298+ demandF
12991299 (toValue . \ case
13001300 NVStr {} -> True
13011301 _ -> False
13021302 )
13031303
13041304isFunction :: MonadNix e t f m => NValue t f m -> m (NValue t f m )
13051305isFunction =
1306- demand
1306+ demandF
13071307 (toValue . \ case
13081308 NVClosure {} -> True
13091309 _ -> False
@@ -1337,7 +1337,7 @@ scopedImport asetArg pathArg =
13371337 traceM " No known current directory"
13381338 pure path
13391339 )
1340- (demand
1340+ (demandF
13411341 (\ pp ->
13421342 do
13431343 (Path p') <- fromValue pp
@@ -1390,9 +1390,9 @@ lessThan
13901390 -> NValue t f m
13911391 -> m (NValue t f m )
13921392lessThan ta tb =
1393- demand
1393+ demandF
13941394 (\ va ->
1395- demand
1395+ demandF
13961396 (\ vb ->
13971397 do
13981398 let
@@ -1420,7 +1420,7 @@ concatLists =
14201420 toValue . concat <=<
14211421 mapM
14221422 (pure <=<
1423- demand $ fromValue @ [NValue t f m ]
1423+ demandF $ fromValue @ [NValue t f m ]
14241424 )
14251425 <=< fromValue @ [NValue t f m ]
14261426
@@ -1447,12 +1447,12 @@ listToAttrs lst =
14471447 fmap
14481448 ((`nvSet` M. empty) . M. fromList . reverse )
14491449 (forM l $
1450- demand
1450+ demandF
14511451 (\ nvattrset ->
14521452 do
14531453 a <- fromValue @ (AttrSet (NValue t f m )) nvattrset
14541454 t <- attrsetGet " name" a
1455- demand
1455+ demandF
14561456 (\ nvstr ->
14571457 do
14581458 n <- fromValue nvstr
@@ -1531,7 +1531,7 @@ absolutePathFromValue =
15311531 v -> throwError $ ErrorCall $ " expected a path, got " <> show v
15321532
15331533readFile_ :: MonadNix e t f m => NValue t f m -> m (NValue t f m )
1534- readFile_ = demand (toValue <=< Nix.Render. readFile <=< absolutePathFromValue)
1534+ readFile_ = demandF (toValue <=< Nix.Render. readFile <=< absolutePathFromValue)
15351535
15361536findFile_
15371537 :: forall e t f m
@@ -1540,9 +1540,9 @@ findFile_
15401540 -> NValue t f m
15411541 -> m (NValue t f m )
15421542findFile_ aset filePath =
1543- demand
1543+ demandF
15441544 (\ aset' ->
1545- demand
1545+ demandF
15461546 (\ filePath' ->
15471547 case (aset', filePath') of
15481548 (NVList x, NVStr ns) -> do
@@ -1573,7 +1573,7 @@ instance Convertible e t f m => ToValue FileType m (NValue t f m) where
15731573readDir_
15741574 :: forall e t f m . MonadNix e t f m => NValue t f m -> m (NValue t f m )
15751575readDir_ =
1576- demand
1576+ demandF
15771577 (\ path' -> do
15781578 path <- absolutePathFromValue path'
15791579 items <- listDirectory path
@@ -1590,7 +1590,7 @@ readDir_ =
15901590fromJSON
15911591 :: forall e t f m . MonadNix e t f m => NValue t f m -> m (NValue t f m )
15921592fromJSON =
1593- demand
1593+ demandF
15941594 (\ j ->
15951595 do
15961596 encoded <- fromStringNoContext =<< fromValue j
@@ -1615,13 +1615,13 @@ fromJSON =
16151615 A. Null -> pure $ nvConstant NNull
16161616
16171617prim_toJSON :: MonadNix e t f m => NValue t f m -> m (NValue t f m )
1618- prim_toJSON = demand (fmap nvStr . nvalueToJSONNixString)
1618+ prim_toJSON = demandF (fmap nvStr . nvalueToJSONNixString)
16191619
16201620toXML_ :: MonadNix e t f m => NValue t f m -> m (NValue t f m )
1621- toXML_ = demand (fmap (nvStr . toXML) . normalForm)
1621+ toXML_ = demandF (fmap (nvStr . toXML) . normalForm)
16221622
16231623typeOf :: MonadNix e t f m => NValue t f m -> m (NValue t f m )
1624- typeOf = demand
1624+ typeOf = demandF
16251625 (toValue . makeNixStringWithoutContext . \ case
16261626 NVConstant a -> case a of
16271627 NURI _ -> " string"
@@ -1640,7 +1640,7 @@ typeOf = demand
16401640
16411641tryEval
16421642 :: forall e t f m . MonadNix e t f m => NValue t f m -> m (NValue t f m )
1643- tryEval e = catch (demand (pure . onSuccess) e) (pure . onError)
1643+ tryEval e = catch (demandF (pure . onSuccess) e) (pure . onError)
16441644 where
16451645 onSuccess v = flip nvSet M. empty $ M. fromList
16461646 [(" success" , nvConstant (NBool True )), (" value" , v)]
@@ -1684,9 +1684,9 @@ exec_ xs = do
16841684fetchurl
16851685 :: forall e t f m . MonadNix e t f m => NValue t f m -> m (NValue t f m )
16861686fetchurl =
1687- demand
1687+ demandF
16881688 (\ case
1689- NVSet s _ -> demand (go (M. lookup " sha256" s)) =<< attrsetGet " url" s
1689+ NVSet s _ -> demandF (go (M. lookup " sha256" s)) =<< attrsetGet " url" s
16901690 v@ NVStr {} -> go Nothing v
16911691 v -> throwError $ ErrorCall $ " builtins.fetchurl: Expected URI or set, got " <> show v
16921692 )
@@ -1748,7 +1748,7 @@ getRecursiveSize = fmap (nvConstant . NInt . fromIntegral) . recursiveSize
17481748getContext
17491749 :: forall e t f m . MonadNix e t f m => NValue t f m -> m (NValue t f m )
17501750getContext =
1751- demand
1751+ demandF
17521752 (\ case
17531753 (NVStr ns) -> do
17541754 let context = getNixLikeContext $ toNixLikeContext $ NixString. getContext ns
@@ -1763,31 +1763,31 @@ appendContext
17631763 -> NValue t f m
17641764 -> m (NValue t f m )
17651765appendContext x y =
1766- demand
1766+ demandF
17671767 (\ x' ->
1768- demand
1768+ demandF
17691769 (\ y' ->
17701770 (case (x', y') of
17711771 (NVStr ns, NVSet attrs _) -> do
17721772 newContextValues <- forM attrs $
1773- demand
1773+ demandF
17741774 (\ case
17751775 NVSet attrs _ -> do
17761776 -- TODO: Fail for unexpected keys.
17771777 path <-
17781778 maybe
17791779 (pure False )
1780- (demand fromValue)
1780+ (demandF fromValue)
17811781 (M. lookup " path" attrs)
17821782 allOutputs <-
17831783 maybe
17841784 (pure False )
1785- (demand fromValue)
1785+ (demandF fromValue)
17861786 (M. lookup " allOutputs" attrs)
17871787 outputs <-
17881788 maybe
17891789 (pure mempty )
1790- (demand
1790+ (demandF
17911791 (\ case
17921792 NVList vs -> forM vs $ fmap stringIgnoreContext . fromValue
17931793 x -> throwError $ ErrorCall $ " Invalid types for context value outputs in builtins.appendContext: " <> show x
0 commit comments