Skip to content

Commit 7fbb8be

Browse files
committed
Nix.Builtins: replaceStrings: m refactor: form process
1 parent 2e081f4 commit 7fbb8be

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/Nix/Builtins.hs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -961,25 +961,24 @@ replaceStrings tfrom tto ts =
961961

962962
go orig resultAccum ctx = case lookupPrefix orig of
963963
Nothing ->
964-
maybe
965-
(finish resultAccum)
966-
(\(h, t) -> go t (resultAccum <> Builder.singleton h))
967-
(Text.uncons orig)
968-
ctx
964+
process resultAccum orig ctx
969965
Just (prefix, replacementNS, rest) ->
970-
(if prefix == mempty
966+
( if prefix == mempty
971967
then
972-
maybe
973-
(finish newResultAccum)
974-
(\(h,t) -> go t (newResultAccum <> Builder.singleton h))
975-
(Text.uncons rest)
968+
process newResultAccum rest
976969
else
977-
go rest newResultAccum)
978-
(ctx <> newCtx)
970+
go rest newResultAccum
971+
) (ctx <> newCtx)
979972
where
980973
replacement = Builder.fromText $ stringIgnoreContext replacementNS
981974
newResultAccum = resultAccum <> replacement
982975
newCtx = NixString.getContext replacementNS
976+
where
977+
process r t =
978+
maybe
979+
(finish r)
980+
(\(h, t) -> go t (r <> Builder.singleton h))
981+
(Text.uncons t)
983982
toValue
984983
$ go (stringIgnoreContext ns) mempty
985984
$ NixString.getContext ns

0 commit comments

Comments
 (0)