File tree Expand file tree Collapse file tree 4 files changed +17
-10
lines changed Expand file tree Collapse file tree 4 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,6 @@ import Data.Set ( member
1919 )
2020import Nix.Cited
2121import Nix.Frames
22- import Nix.String
2322import Nix.Thunk
2423import Nix.Value
2524
@@ -156,7 +155,7 @@ stubCycles
156155 -> NValue t f m
157156stubCycles =
158157 iterNValue
159- (\ t _ ->
158+ (\ _ t ->
160159 Free $
161160 NValue' $
162161 foldr
Original file line number Diff line number Diff line change @@ -307,7 +307,7 @@ exprFNixDoc = \case
307307
308308
309309valueToExpr :: forall t f m . MonadDataContext f m => NValue t f m -> NExpr
310- valueToExpr = iterNValue ( \ _ _ -> thk) (Fix . phi)
310+ valueToExpr = iterNValueByDiscardWith thk (Fix . phi)
311311 where
312312 thk = Fix . NSym $ " <expr>"
313313
@@ -372,7 +372,7 @@ prettyNThunk t =
372372
373373-- | This function is used only by the testing code.
374374printNix :: forall t f m . MonadDataContext f m => NValue t f m -> String
375- printNix = iterNValue ( \ _ _ -> thk) phi
375+ printNix = iterNValueByDiscardWith thk phi
376376 where
377377 thk = toString thunkStubText
378378
Original file line number Diff line number Diff line change @@ -513,18 +513,26 @@ type NValue t f m = Free (NValue' t f m) t
513513
514514-- ** Free
515515
516- -- | @iter@
516+ -- | HOF of @iter@ from @Free @
517517iterNValue
518518 :: forall t f m r
519519 . MonadDataContext f m
520- => (t -> (NValue t f m -> r ) -> r )
520+ => (( Free (NValue' t f m ) t -> r ) -> t -> r )
521521 -> (NValue' t f m r -> r )
522- -> NValue t f m
522+ -> Free (NValue' t f m ) t
523+ -> r
524+ iterNValue k f = iter f . fmap (k (iterNValue k f))
525+
526+ iterNValueByDiscardWith
527+ :: MonadDataContext f m
528+ => r
529+ -> (NValue' t f m r -> r )
530+ -> Free (NValue' t f m ) t
523531 -> r
524- iterNValue k f = iter f . fmap ( \ t -> k t $ iterNValue k f )
532+ iterNValueByDiscardWith dflt = iterNValue ( \ _ _ -> dflt )
525533
526534
527- -- | @iter@ for monadic values
535+ -- | HOF of @iterM@ from @Free@
528536iterNValueM
529537 :: (MonadDataContext f m , Monad n )
530538 => (forall x . n x -> m x )
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ import Text.XML.Light ( Element(Element)
1717 )
1818
1919toXML :: forall t f m . MonadDataContext f m => NValue t f m -> NixString
20- toXML = runWithStringContext . fmap pp . iterNValue ( \ _ _ -> cyc) phi
20+ toXML = runWithStringContext . fmap pp . iterNValueByDiscardWith cyc phi
2121 where
2222 cyc = pure $ mkEVal " string" " <expr>"
2323
You can’t perform that action at this time.
0 commit comments