Skip to content

Commit 12816f6

Browse files
committed
String: clean-up
1 parent b88f3f4 commit 12816f6

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/Nix/String.hs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ toStringContexts :: (VarName, NixLikeContextValue) -> [StringContext]
180180
toStringContexts ~(path, nlcv) =
181181
go nlcv
182182
where
183-
183+
go :: NixLikeContextValue -> [StringContext]
184184
go cv =
185185
case cv of
186186
NixLikeContextValue True _ _ ->
@@ -191,7 +191,10 @@ toStringContexts ~(path, nlcv) =
191191
mkCtxFor . DerivationOutput <$> ls
192192
_ -> mempty
193193
where
194+
mkCtxFor :: ContextFlavor -> StringContext
194195
mkCtxFor = StringContext path
196+
197+
mkLstCtxFor :: ContextFlavor -> NixLikeContextValue -> [StringContext]
195198
mkLstCtxFor t c = mkCtxFor t : go c
196199

197200
toNixLikeContextValue :: StringContext -> (VarName, NixLikeContextValue)
@@ -207,11 +210,12 @@ toNixLikeContext :: S.HashSet StringContext -> NixLikeContext
207210
toNixLikeContext stringContext =
208211
NixLikeContext $
209212
S.foldr
210-
go
213+
fun
211214
mempty
212215
stringContext
213216
where
214-
go sc hm =
217+
fun :: (StringContext -> AttrSet NixLikeContextValue -> AttrSet NixLikeContextValue)
218+
fun sc hm =
215219
let (t, nlcv) = toNixLikeContextValue sc in
216220
M.insertWith (<>) t nlcv hm
217221

@@ -258,12 +262,15 @@ intercalateNixString sep nss =
258262
uncurry NixString $ mapPair intertwine unpackNss
259263
where
260264

265+
intertwine :: ([Text] -> Text, [HashSet StringContext] -> HashSet StringContext)
261266
intertwine =
262267
( Text.intercalate (nsContents sep)
263268
, S.unions . (:) (nsContext sep)
264269
)
265270

271+
unpackNss :: ([Text], [HashSet StringContext])
266272
unpackNss = (fnss nsContents, fnss nsContext)
267273
where
274+
fnss :: (NixString -> b) -> [b]
268275
fnss = (`fmap` nss) -- do once
269276

0 commit comments

Comments
 (0)