Skip to content

Commit 147ba1e

Browse files
committed
(hacky->principled)GetStringNoContext
1 parent 67fe11c commit 147ba1e

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/Nix/Convert.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ instance ( Convertible e t f m
166166
instance Convertible e t f m
167167
=> FromValue ByteString m (NValue' t f m (NValue t f m)) where
168168
fromValueMay = \case
169-
NVStr' ns -> pure $ encodeUtf8 <$> hackyGetStringNoContext ns
169+
NVStr' ns -> pure $ encodeUtf8 <$> principledGetStringNoContext ns
170170
_ -> pure Nothing
171171
fromValue v = fromValueMay v >>= \case
172172
Just b -> pure b
@@ -181,7 +181,7 @@ instance ( Convertible e t f m
181181
=> FromValue Path m (NValue' t f m (NValue t f m)) where
182182
fromValueMay = \case
183183
NVPath' p -> pure $ Just (Path p)
184-
NVStr' ns -> pure $ Path . Text.unpack <$> hackyGetStringNoContext ns
184+
NVStr' ns -> pure $ Path . Text.unpack <$> principledGetStringNoContext ns
185185
NVSet' s _ -> case M.lookup "outPath" s of
186186
Nothing -> pure Nothing
187187
Just p -> fromValueMay @Path p

src/Nix/String.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,6 @@ principledStringMConcat =
155155
-- mempty = NixString mempty mempty
156156
-- mappend = (<>)
157157

158-
-- | Extract the string contents from a NixString that has no context
159-
hackyGetStringNoContext :: NixString -> Maybe Text
160-
hackyGetStringNoContext (NixString s c) | null c = Just s
161-
| otherwise = Nothing
162-
163158
-- | Extract the string contents from a NixString that has no context
164159
principledGetStringNoContext :: NixString -> Maybe Text
165160
principledGetStringNoContext (NixString s c) | null c = Just s
@@ -252,3 +247,7 @@ hackyMakeNixStringWithoutContext = principledMakeNixStringWithoutContext
252247
hackyStringIgnoreContext :: NixString -> Text
253248
hackyStringIgnoreContext = principledStringIgnoreContext
254249

250+
-- | Extract the string contents from a NixString that has no context
251+
hackyGetStringNoContext :: NixString -> Maybe Text
252+
hackyGetStringNoContext = principledGetStringNoContext
253+

0 commit comments

Comments
 (0)