uhc-util 0.1.5.5 → 0.1.5.6
raw patch · 4 files changed
+41/−5 lines, 4 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ UHC.Util.RelMap: delete :: (Ord a, Ord b) => a -> Rel a b -> Rel a b
+ UHC.Util.RelMap: deleteDom :: (Ord a, Ord b) => a -> Rel a b -> Rel a b
+ UHC.Util.RelMap: deleteRng :: (Ord a, Ord b) => b -> Rel a b -> Rel a b
+ UHC.Util.RelMap: toDomList :: Rel a b -> [(a, [b])]
+ UHC.Util.RelMap: toRngList :: Rel a b -> [([a], b)]
Files
- changelog.md +4/−0
- src/UHC/Util/FPath.hs +2/−2
- src/UHC/Util/RelMap.hs +34/−2
- uhc-util.cabal +1/−1
changelog.md view
@@ -1,5 +1,9 @@ # Changelog +## 0.1.5.6++- [??]+ ## 0.1.5.5 - [compatibility] GHC 7.10 compatibility: sortOn has become more strict, addition of a sortOnLazy
src/UHC/Util/FPath.hs view
@@ -252,8 +252,8 @@ -- | Make FPath from FilePath, setting the suffix when absent mkTopLevelFPath- :: String -- ^ suffix- -> FilePath -- ^ file name+ :: String -- ^ suffix+ -> FilePath -- ^ file name -> FPath mkTopLevelFPath suff fn = let fpNoSuff = mkFPath fn
src/UHC/Util/RelMap.hs view
@@ -4,6 +4,7 @@ module UHC.Util.RelMap ( Rel , empty+ , toDomList, toRngList , toList, fromList , singleton , dom, rng@@ -13,6 +14,8 @@ -- , intersection, difference , union, unions , insert+ , deleteDom, delete+ , deleteRng , applyDomMbSet, applyRngMbSet , applyDomSet, applyRngSet@@ -36,12 +39,23 @@ import UHC.Util.Serialize ---------------------------------------------------------------------------- Relation+-- Relation map ------------------------------------------------------------------------- -- | Map used in a relation type RelMap a b = Map.Map a (Set.Set b) +-- | Delete key in range of RelMap+relmapDeleteRng :: Ord b => b -> RelMap a b -> RelMap a b+relmapDeleteRng x r = snd $ Map.mapEither (eith x) r+ where eith x ds = if Set.null ds' then Left ds else Right ds'+ where (ds1,ds2) = Set.split x ds+ ds' = Set.union ds1 ds2++-------------------------------------------------------------------------+-- Relation+-------------------------------------------------------------------------+ -- | Relation, represented as 2 maps from domain to range and the inverse, thus allowing faster lookup at the expense of some set like operations more expensive. data Rel a b = Rel@@ -49,9 +63,17 @@ , relRngMp :: RelMap b a -- ^ from range to domain } +-- | As assocation list where each domain value only occurs once and the range as list+toDomList :: Rel a b -> [(a,[b])]+toDomList (Rel m _) = [ (d, Set.toList rs) | (d,rs) <- Map.toList m ]++-- | As assocation list where each range value only occurs once and the domain as list+toRngList :: Rel a b -> [([a],b)]+toRngList (Rel _ m) = [ (Set.toList ds, r) | (r,ds) <- Map.toList m ]+ -- | As assocation list toList :: Rel a b -> [(a,b)]-toList (Rel m _) = [ (d,r) | (d,rs) <- Map.toList m, r <- Set.toList rs ]+toList rel = [ (d,r) | (d,rs) <- toDomList rel, r <- rs ] -- | From association list fromList :: (Ord a, Ord b) => [(a,b)] -> Rel a b@@ -124,6 +146,16 @@ -- | Insert insert :: (Ord a, Ord b) => a -> b -> Rel a b -> Rel a b insert x y r = singleton x y `union` r++-- | Delete at domain+deleteDom, delete :: (Ord a, Ord b) => a -> Rel a b -> Rel a b+deleteDom x (Rel d r) = Rel (Map.delete x d) (relmapDeleteRng x r)+delete = deleteDom+{-# INLINE delete #-}++-- | Delete at range+deleteRng :: (Ord a, Ord b) => b -> Rel a b -> Rel a b+deleteRng x (Rel d r) = Rel (relmapDeleteRng x d) (Map.delete x r) -- | Apply relation as a function, possible yielding a non empty set applyDomMbSet :: (Ord a) => Rel a b -> a -> Maybe (Set.Set b)
uhc-util.cabal view
@@ -1,5 +1,5 @@ Name: uhc-util-Version: 0.1.5.5+Version: 0.1.5.6 cabal-version: >= 1.6 License: BSD3 Copyright: Utrecht University, Department of Information and Computing Sciences, Software Technology group