diff --git a/src/Data/Id.hs b/src/Data/Id.hs index 59ec8d4..f13cb6e 100644 --- a/src/Data/Id.hs +++ b/src/Data/Id.hs @@ -19,14 +19,15 @@ module Data.Id ( , register , singleton , size + , toList , union ) where import Control.Monad.State.Strict (MonadState, modify, gets) import Data.IntMap (IntMap, (!)) import qualified Data.IntMap as IntMap ( - delete, empty, filterWithKey, fromList, keysSet, insert, lookup - , mapWithKey, maxViewWithKey, member, minViewWithKey, size, union + delete, empty, filterWithKey, fromList, keysSet, insert, lookup, mapWithKey + , maxViewWithKey, member, minViewWithKey, size, toList, union ) import Data.IntSet (IntSet) import Prelude hiding (lookup) @@ -81,6 +82,9 @@ filterWithKey f = IdMap . IntMap.filterWithKey (f . Id) . intMap fromList :: [(Id a, b)] -> IdMap a b fromList = IdMap . IntMap.fromList . fmap (\(key, b) -> (getId key, b)) +toList :: IdMap a b -> [(Id a, b)] +toList = fmap (\(key, b) -> (Id key, b)) . IntMap.toList . intMap + keysSet :: IdMap a b -> IntSet keysSet = IntMap.keysSet . intMap