Skip to content

Commit 5f096dd

Browse files
committed
Utils: rm alterF (used once)
1 parent 51f6734 commit 5f096dd

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/Nix/Expr/Types.hs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import Data.Data
3232
import Data.Fix
3333
import Data.Functor.Classes
3434
import Data.Hashable.Lifted
35+
import qualified Data.HashMap.Lazy as MapL
3536
import qualified Data.List.NonEmpty as NE
3637
import qualified Text.Show
3738
import Data.Traversable
@@ -615,7 +616,19 @@ hashAt
615616
#else
616617
hashAt :: VarName -> Lens' (AttrSet v) (Maybe v)
617618
#endif
618-
hashAt = flip alterF
619+
hashAt = alterF
620+
where
621+
alterF
622+
:: (Functor f)
623+
=> Text
624+
-> (Maybe v -> f (Maybe v))
625+
-> AttrSet v
626+
-> f (AttrSet v)
627+
alterF k f m =
628+
maybe
629+
(MapL.delete k m)
630+
(\ v -> MapL.insert k v m)
631+
<$> f (MapL.lookup k m)
619632

620633
-- | Get the name out of the parameter (there might be none).
621634
paramName :: Params r -> Maybe VarName

src/Nix/Utils.hs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,6 @@ uriAwareSplit txt =
172172
(e1 <> "://" <> suffix, PathEntryURI) : path
173173
| otherwise -> (e1, PathEntryPath) : uriAwareSplit (Text.drop 1 e2)
174174

175-
alterF
176-
:: (Eq k, Hashable k, Functor f)
177-
=> (Maybe v -> f (Maybe v))
178-
-> k
179-
-> HashMap k v
180-
-> f (HashMap k v)
181-
alterF f k m =
182-
maybe
183-
(M.delete k m)
184-
(\ v -> M.insert k v m)
185-
<$> f (M.lookup k m)
186-
187-
188175
-- | Analog for @bool@ or @maybe@, for list-like cons structures.
189176
list
190177
:: Foldable t

0 commit comments

Comments
 (0)