ixset-typed-conversions 0.1.1.1 → 0.1.2.0
raw patch · 3 files changed
+17/−1 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.IxSet.Typed.Conversions: toHashMapBy' :: (Hashable a, IsIndexOf a xs, Indexable xs k) => IxSet xs k -> (a -> IxSet xs k -> k') -> HashMap a k'
+ Data.IxSet.Typed.Conversions: toHashMapByM' :: (Monad m, Hashable a, IsIndexOf a xs, Indexable xs k) => IxSet xs k -> (a -> IxSet xs k -> m k') -> m (HashMap a k')
Files
- ChangeLog.md +4/−0
- ixset-typed-conversions.cabal +1/−1
- src/Data/IxSet/Typed/Conversions.hs +12/−0
ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for ixset-typed-conversions +## (v0.1.2.0)++* Add `toHashMapBy'` and `toHashMapByM'`.+ ## (v0.1.1.0) * Add cofree conversions.
ixset-typed-conversions.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: ixset-typed-conversions-version: 0.1.1.1+version: 0.1.2.0 synopsis: Conversions from ixset-typed to other containers. description: Conversions from ixset-typed to other containers; HashMaps, zippers. category: Data Structures
src/Data/IxSet/Typed/Conversions.hs view
@@ -10,6 +10,8 @@ toHashMap , toHashMapBy , toHashMapByM+, toHashMapBy'+, toHashMapByM' , toZipperAsc , toZipperDesc , toAscCofreeList@@ -41,6 +43,16 @@ toHashMapByM :: (Monad m, Hashable a, IsIndexOf a xs) => IxSet xs k -> (a -> [k] -> m k') -> m (HM.HashMap a k') toHashMapByM xs f = fmap HM.fromList $ forM (Ix.groupDescBy xs) $ \(a, ks) -> do z <- f a ks+ return (a, z)++-- | Like `toHashMapBy`, but uses a function on the requeried `IxSet` for that key.+toHashMapBy' :: (Hashable a, IsIndexOf a xs, Indexable xs k) => IxSet xs k -> (a -> IxSet xs k -> k') -> HM.HashMap a k'+toHashMapBy' xs f = HM.fromList $ flip map (Ix.indexKeys xs) $ \a -> (a, f a (xs Ix.@+ [a]))++-- | Like `toHashMapByM`, but uses a function on the requeried `IxSet` for that key.+toHashMapByM' :: (Monad m, Hashable a, IsIndexOf a xs, Indexable xs k) => Ix.IxSet xs k -> (a -> Ix.IxSet xs k -> m k') -> m (HM.HashMap a k')+toHashMapByM' xs f = fmap HM.fromList $ forM (Ix.indexKeys xs) $ \a -> do+ z <- f a (xs Ix.@+ [a]) return (a, z) -- | Convert an `IxSet` to a `Zipper` by descending sort on an index.