@@ -953,7 +953,7 @@ replaceStrings tfrom tto ts =
953953 -- And moreover, the `passOneCharNgo` passively passes the context, to context can be removed from it and inherited directly.
954954 -- Then the solution would've been elegant, but the Nix bug prevents elegant implementation.
955955 go remaining processed ctx =
956- case maybePrefixMatch remaining of
956+ case maybePrefixMatch of
957957 Nothing ->
958958 -- Pass the chars until match
959959 passOneCharNgo remaining processed ctx
@@ -983,16 +983,18 @@ replaceStrings tfrom tto ts =
983983
984984 where
985985 -- When prefix matched something - returns (match, replacement, reminder)
986- maybePrefixMatch :: Text -> Maybe (Text , NixString , Text )
987- maybePrefixMatch src = (\ (m, r) -> (m, r, Text. drop (Text. length m) src)) <$> find ((`Text.isPrefixOf` src) . fst ) fromKeysToValsMap
986+ maybePrefixMatch :: Maybe (Text , NixString , Text )
987+ maybePrefixMatch = formMatchReplaceNTail <$> find ((`Text.isPrefixOf` remaining) . fst ) fromKeysToValsMap
988+
989+ formMatchReplaceNTail = (\ (m, r) -> (m, r, Text. drop (Text. length m) remaining))
988990
989991 fromKeysToValsMap = zip (fmap stringIgnoreContext fromKeys) toVals
990992
991- passOneCharNgo text result =
993+ passOneCharNgo input output =
992994 maybe
993- (finish result ) -- The base case - there is no chars left to process -> finish
994- (\ (c, t) -> go t (result <> Builder. singleton c)) -- If there are chars - pass one char & continue
995- (Text. uncons text ) -- chip first char
995+ (finish output ) -- The base case - there is no chars left to process -> finish
996+ (\ (c, t) -> go t (output <> Builder. singleton c)) -- If there are chars - pass one char & continue
997+ (Text. uncons input ) -- chip first char
996998
997999 finish = makeNixString . LazyText. toStrict . Builder. toLazyText
9981000
0 commit comments