git.iko.soy/typeable/ordered-containers
on d4fd56e help sign in
ChangeLog.md−5
since splitsnapshots
unifiedsplit
@@ -1,10 +1,5 @@
1# Revision history for ordered-containers
1# Revision history for ordered-containers
2
2
3−## 0.2.2 -- 2019-07-05
4−
5−* Add `toMap` and `toSet`, which support efficient conversions from
6− `OMap`s/`OSet`s to `Map`s/`Set`s, respectively.
7−
8## 0.2.1 -- 2019-03-25
3## 0.2.1 -- 2019-03-25
9
4
10* Compatibility fixes from Ryan Scott (thanks!)
5* Compatibility fixes from Ryan Scott (thanks!)
Data/Map/Ordered.hs−2
@@ -32,8 +32,6 @@ module Data.Map.Ordered
32 , Index, findIndex, elemAt
32 , Index, findIndex, elemAt
33 -- * List conversions
33 -- * List conversions
34 , fromList, assocs, toAscList
34 , fromList, assocs, toAscList
35− -- * 'M.Map' conversion
36− , toMap
37 ) where
35 ) where
38
36
39import qualified Data.Map as M ()
37import qualified Data.Map as M ()
Data/Map/Ordered/Internal.hs−6
@@ -242,9 +242,3 @@ assocs (OMap _ kvs) = map snd $ M.toAscList kvs
242-- | Return key-value pairs in order of increasing key.
242-- | Return key-value pairs in order of increasing key.
243toAscList :: OMap k v -> [(k, v)]
243toAscList :: OMap k v -> [(k, v)]
244toAscList (OMap tvs kvs) = map (\(k, (t, v)) -> (k, v)) $ M.toAscList tvs
244toAscList (OMap tvs kvs) = map (\(k, (t, v)) -> (k, v)) $ M.toAscList tvs
245−
246−-- | Convert an 'OMap' to a 'Map'.
247−--
248−-- /O(n)/, where /n/ is the size of the 'OMap'.
249−toMap :: OMap k v -> Map k v
250−toMap (OMap tvs _) = fmap snd tvs
Data/Map/Ordered/Strict.hs+2−4
@@ -32,15 +32,13 @@ module Data.Map.Ordered.Strict
32 , Index, findIndex, elemAt
32 , Index, findIndex, elemAt
33 -- * List conversions
33 -- * List conversions
34 , fromList, assocs, toAscList
34 , fromList, assocs, toAscList
35− -- * 'M.Map' conversion
36− , toMap
37 ) where
35 ) where
38
36
39import Data.Foldable (foldl')
37import Data.Foldable (foldl')
40import qualified Data.Map.Strict as M
38import qualified Data.Map.Strict as M
41import Data.Map.Ordered.Internal
39import Data.Map.Ordered.Internal
42− ( OMap(..), empty, (<>|), (|<>), delete, filter, (\\), (|/\), (/\|), null, size
40+ ( OMap(..), empty, (<>|), (|<>), delete, filter, (\\), (|/\), (/\|), null, size
43− , member, notMember, lookup, findIndex, elemAt, assocs, toAscList, fromTV, toMap )
41+ , member, notMember, lookup, findIndex, elemAt, assocs, toAscList, fromTV )
44import Data.Map.Util
42import Data.Map.Util
45import Prelude hiding (filter, lookup, null)
43import Prelude hiding (filter, lookup, null)
46
44
Data/Map/Util.hs−13
@@ -1,23 +1,12 @@
1−{-# LANGUAGE CPP #-}
2{-# LANGUAGE DataKinds #-}
1{-# LANGUAGE DataKinds #-}
3−{-# LANGUAGE DeriveDataTypeable #-}
4−{-# LANGUAGE DeriveFoldable #-}
5−{-# LANGUAGE DeriveFunctor #-}
6−{-# LANGUAGE DeriveTraversable #-}
7{-# LANGUAGE KindSignatures #-}
2{-# LANGUAGE KindSignatures #-}
8
3
9module Data.Map.Util where
4module Data.Map.Util where
10
5
11−import Data.Data (Data, Typeable)
12import Data.Map (Map)
6import Data.Map (Map)
13import Data.Monoid -- so that the docs for Monoid link to the right place
7import Data.Monoid -- so that the docs for Monoid link to the right place
14import qualified Data.Map as M
8import qualified Data.Map as M
15
9
16−#if !(MIN_VERSION_base(4,8,0))
17−import Data.Foldable (Foldable)
18−import Data.Traversable (Traversable)
19−#endif
20−
21-- | An internal index used to track ordering only -- its magnitude doesn't
10-- | An internal index used to track ordering only -- its magnitude doesn't
22-- matter. If you manage to see this documentation, the library author has made
11-- matter. If you manage to see this documentation, the library author has made
23-- a mistake!
12-- a mistake!
@@ -49,8 +38,6 @@ readsPrecList fromList d = readParen (d > 10) $ \r -> do
49-- tells whether 'mappend' will prefer the indices of its first or second
38-- tells whether 'mappend' will prefer the indices of its first or second
50-- argument if there are shared elements in both.
39-- argument if there are shared elements in both.
51newtype Bias (dir :: IndexPreference) a = Bias { unbiased :: a }
40newtype Bias (dir :: IndexPreference) a = Bias { unbiased :: a }
52− deriving (Data, Eq, Foldable, Functor, Ord, Read, Show, Traversable, Typeable)
53data IndexPreference = L | R
41data IndexPreference = L | R
54− deriving Typeable
55type L = 'L
42type L = 'L
56type R = 'R
43type R = 'R
Data/Set/Ordered.hs−8
@@ -28,8 +28,6 @@ module Data.Set.Ordered
28 , Index, findIndex, elemAt
28 , Index, findIndex, elemAt
29 -- * List conversions
29 -- * List conversions
30 , fromList, toAscList
30 , fromList, toAscList
31− -- * 'Set' conversion
32− , toSet
33 ) where
31 ) where
34
32
35import Control.Monad (guard)
33import Control.Monad (guard)
@@ -218,9 +216,3 @@ elemAt o@(OSet ts vs) i = do
218-- insertion order.)
216-- insertion order.)
219toAscList :: OSet a -> [a]
217toAscList :: OSet a -> [a]
220toAscList o@(OSet ts _) = fmap fst (M.toAscList ts)
218toAscList o@(OSet ts _) = fmap fst (M.toAscList ts)
221−
222−-- | Convert an 'OSet' to a 'Set'.
223−--
224−-- /O(n)/, where /n/ is the size of the 'OSet'.
225−toSet :: OSet a -> Set a
226−toSet (OSet ts _) = M.keysSet ts
ordered-containers.cabal+1−1
@@ -1,5 +1,5 @@
1name: ordered-containers
1name: ordered-containers
2−version: 0.2.2
2+version: 0.2.1
3synopsis: Set- and Map-like types that remember the order elements were inserted
3synopsis: Set- and Map-like types that remember the order elements were inserted
4license: BSD3
4license: BSD3
5license-file: LICENSE
5license-file: LICENSE