Skip to content

Commit 41be26c

Browse files
committed
Nix/String: principle the remaining hacky implementations
1 parent 147ba1e commit 41be26c

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/Nix/Builtins.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,9 +1015,6 @@ toFile
10151015
toFile name s = do
10161016
name' <- fromStringNoContext =<< fromValue name
10171017
s' <- fromValue s
1018-
-- TODO Using hacky here because we still need to turn the context into
1019-
-- runtime references of the resulting file.
1020-
-- See prim_toFile in nix/src/libexpr/primops.cc
10211018
mres <- toFile_ (Text.unpack name')
10221019
(Text.unpack $ principledStringIgnoreContext s')
10231020
let t = Text.pack $ unStorePath mres

src/Nix/String.hs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ module Nix.String
1515
, fromNixLikeContext
1616
, stringHasContext
1717
, principledIntercalateNixString
18-
, hackyGetStringNoContext
1918
, principledGetStringNoContext
2019
, principledStringIgnoreContext
21-
, hackyStringIgnoreContext
22-
, hackyMakeNixStringWithoutContext
2320
, principledMakeNixStringWithoutContext
2421
, principledMakeNixStringWithSingletonContext
2522
, principledModifyNixContents
@@ -35,6 +32,9 @@ module Nix.String
3532
, runWithStringContextT'
3633
, runWithStringContext
3734
, runWithStringContext'
35+
, hackyGetStringNoContext
36+
, hackyStringIgnoreContext
37+
, hackyMakeNixStringWithoutContext
3838
)
3939
where
4040

@@ -232,12 +232,11 @@ runWithStringContext' = runIdentity . runWithStringContextT'
232232

233233
-- | Combine two NixStrings using mappend
234234
hackyStringMappend :: NixString -> NixString -> NixString
235-
hackyStringMappend (NixString s1 t1) (NixString s2 t2) =
236-
NixString (s1 <> s2) (t1 <> t2)
235+
hackyStringMappend = principledStringMappend
237236

238237
-- | Combine NixStrings using mconcat
239238
hackyStringMConcat :: [NixString] -> NixString
240-
hackyStringMConcat = foldr principledStringMappend (NixString mempty mempty)
239+
hackyStringMConcat = principledStringMConcat
241240

242241
-- | Constructs a NixString without a context
243242
hackyMakeNixStringWithoutContext :: Text -> NixString

0 commit comments

Comments
 (0)