Skip to content

Commit

Permalink
Utils: rm alterF (used once)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton-Latukha committed Jul 16, 2021
1 parent 51f6734 commit 5f096dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
15 changes: 14 additions & 1 deletion src/Nix/Expr/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import Data.Data
import Data.Fix
import Data.Functor.Classes
import Data.Hashable.Lifted
import qualified Data.HashMap.Lazy as MapL
import qualified Data.List.NonEmpty as NE
import qualified Text.Show
import Data.Traversable
Expand Down Expand Up @@ -615,7 +616,19 @@ hashAt
#else
hashAt :: VarName -> Lens' (AttrSet v) (Maybe v)
#endif
hashAt = flip alterF
hashAt = alterF
where
alterF
:: (Functor f)
=> Text
-> (Maybe v -> f (Maybe v))
-> AttrSet v
-> f (AttrSet v)
alterF k f m =
maybe
(MapL.delete k m)
(\ v -> MapL.insert k v m)
<$> f (MapL.lookup k m)

-- | Get the name out of the parameter (there might be none).
paramName :: Params r -> Maybe VarName
Expand Down
13 changes: 0 additions & 13 deletions src/Nix/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,6 @@ uriAwareSplit txt =
(e1 <> "://" <> suffix, PathEntryURI) : path
| otherwise -> (e1, PathEntryPath) : uriAwareSplit (Text.drop 1 e2)

alterF
:: (Eq k, Hashable k, Functor f)
=> (Maybe v -> f (Maybe v))
-> k
-> HashMap k v
-> f (HashMap k v)
alterF f k m =
maybe
(M.delete k m)
(\ v -> M.insert k v m)
<$> f (M.lookup k m)


-- | Analog for @bool@ or @maybe@, for list-like cons structures.
list
:: Foldable t
Expand Down

0 comments on commit 5f096dd

Please sign in to comment.