git.iko.soy/typeable/ordered-containers
on master help sign in
five years is a long enough support window
4ea5084Daniel Wagner
Data/Map/Ordered.hs+4−17
@@ -1,8 +1,5 @@
1−{-# LANGUAGE CPP #-}
1+{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE DeriveFunctor #-}
2{-# LANGUAGE DeriveFunctor #-}
3−#if __GLASGOW_HASKELL__
4−{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-}
5−#endif
6
3
7-- | An 'OMap' behaves much like a 'Map', with all the same asymptotics, but
4-- | An 'OMap' behaves much like a 'Map', with all the same asymptotics, but
8-- also remembers the order that keys were inserted.
5-- also remembers the order that keys were inserted.
@@ -33,6 +30,7 @@ module Data.Map.Ordered
33
30
34import Control.Applicative ((<|>))
31import Control.Applicative ((<|>))
35import Control.Monad (guard)
32import Control.Monad (guard)
33+import Data.Data
36import Data.Foldable (Foldable, foldl', foldMap)
34import Data.Foldable (Foldable, foldl', foldMap)
37import Data.Function (on)
35import Data.Function (on)
38import Data.Map (Map)
36import Data.Map (Map)
@@ -40,11 +38,8 @@ import Data.Map.Util (Index, Tag, maxTag, minTag, nextHigherTag, nextLowerTag, r
40import Prelude hiding (filter, lookup, null)
38import Prelude hiding (filter, lookup, null)
41import qualified Data.Map as M
39import qualified Data.Map as M
42
40
43−#if __GLASGOW_HASKELL__
44−import Data.Data
45−#endif
46−
47−data OMap k v = OMap !(Map k (Tag, v)) !(Map Tag (k, v)) deriving Functor
41+data OMap k v = OMap !(Map k (Tag, v)) !(Map Tag (k, v))
42+ deriving (Functor, Typeable)
48
43
49-- | Values are produced in insertion order, not key order.
44-- | Values are produced in insertion order, not key order.
50instance Foldable (OMap k) where foldMap f (OMap _ kvs) = foldMap (f . snd) kvs
45instance Foldable (OMap k) where foldMap f (OMap _ kvs) = foldMap (f . snd) kvs
@@ -53,13 +48,6 @@ instance ( Ord k, Ord v) => Ord (OMap k v) where compare = compare `on`
53instance ( Show k, Show v) => Show (OMap k v) where showsPrec = showsPrecList assocs
48instance ( Show k, Show v) => Show (OMap k v) where showsPrec = showsPrecList assocs
54instance (Ord k, Read k, Read v) => Read (OMap k v) where readsPrec = readsPrecList fromList
49instance (Ord k, Read k, Read v) => Read (OMap k v) where readsPrec = readsPrecList fromList
55
50
56−#if __GLASGOW_HASKELL__
57−# if __GLASGOW_HASKELL__ >= 708
58−deriving instance Typeable OMap
59−# else
60−deriving instance Typeable2 OMap
61−# endif
62−
63-- This instance preserves data abstraction at the cost of inefficiency.
51-- This instance preserves data abstraction at the cost of inefficiency.
64-- We provide limited reflection services for the sake of data abstraction.
52-- We provide limited reflection services for the sake of data abstraction.
65
53
@@ -77,7 +65,6 @@ fromListConstr = mkConstr oMapDataType "fromList" [] Prefix
77
65
78oMapDataType :: DataType
66oMapDataType :: DataType
79oMapDataType = mkDataType "Data.Map.Ordered.Map" [fromListConstr]
67oMapDataType = mkDataType "Data.Map.Ordered.Map" [fromListConstr]
80−#endif
81
68
82infixr 5 <|, |< -- copy :
69infixr 5 <|, |< -- copy :
83infixl 5 >|, |>
70infixl 5 >|, |>
Data/Set/Ordered.hs+3−16
@@ -1,7 +1,4 @@
1−{-# LANGUAGE CPP #-}
2−#if __GLASGOW_HASKELL__
3−{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-}
1+{-# LANGUAGE DeriveDataTypeable #-}
4−#endif
5
2
6-- | An 'OSet' behaves much like a 'Set', with all the same asymptotics, but
3-- | An 'OSet' behaves much like a 'Set', with all the same asymptotics, but
7-- also remembers the order that values were inserted.
4-- also remembers the order that values were inserted.
@@ -30,6 +27,7 @@ module Data.Set.Ordered
30 ) where
27 ) where
31
28
32import Control.Monad (guard)
29import Control.Monad (guard)
30+import Data.Data
33import Data.Foldable (Foldable, foldl', foldMap, foldr, toList)
31import Data.Foldable (Foldable, foldl', foldMap, foldr, toList)
34import Data.Function (on)
32import Data.Function (on)
35import Data.Map (Map)
33import Data.Map (Map)
@@ -38,11 +36,8 @@ import Data.Set (Set) -- so the haddocks link to the right place
38import Prelude hiding (filter, foldr, lookup, null)
36import Prelude hiding (filter, foldr, lookup, null)
39import qualified Data.Map as M
37import qualified Data.Map as M
40
38
41−#if __GLASGOW_HASKELL__
42−import Data.Data
43−#endif
44−
45data OSet a = OSet !(Map a Tag) !(Map Tag a)
39data OSet a = OSet !(Map a Tag) !(Map Tag a)
40+ deriving Typeable
46
41
47-- | Values appear in insertion order, not ascending order.
42-- | Values appear in insertion order, not ascending order.
48instance Foldable OSet where foldMap f (OSet _ vs) = foldMap f vs
43instance Foldable OSet where foldMap f (OSet _ vs) = foldMap f vs
@@ -51,13 +46,6 @@ instance Ord a => Ord (OSet a) where compare = compare `on` toList
51instance Show a => Show (OSet a) where showsPrec = showsPrecList toList
46instance Show a => Show (OSet a) where showsPrec = showsPrecList toList
52instance (Ord a, Read a) => Read (OSet a) where readsPrec = readsPrecList fromList
47instance (Ord a, Read a) => Read (OSet a) where readsPrec = readsPrecList fromList
53
48
54−#if __GLASGOW_HASKELL__
55−# if __GLASGOW_HASKELL__ >= 708
56−deriving instance Typeable OSet
57−# else
58−deriving instance Typeable1 OSet
59−# endif
60−
61-- This instance preserves data abstraction at the cost of inefficiency.
49-- This instance preserves data abstraction at the cost of inefficiency.
62-- We provide limited reflection services for the sake of data abstraction.
50-- We provide limited reflection services for the sake of data abstraction.
63
51
@@ -75,7 +63,6 @@ fromListConstr = mkConstr oSetDataType "fromList" [] Prefix
75
63
76oSetDataType :: DataType
64oSetDataType :: DataType
77oSetDataType = mkDataType "Data.Set.Ordered.Set" [fromListConstr]
65oSetDataType = mkDataType "Data.Set.Ordered.Set" [fromListConstr]
78−#endif
79
66
80infixr 5 <|, |< -- copy :
67infixr 5 <|, |< -- copy :
81infixl 5 >|, |>
68infixl 5 >|, |>
ordered-containers.cabal+1−1
@@ -23,7 +23,7 @@ library
23 exposed-modules: Data.Map.Ordered, Data.Set.Ordered
23 exposed-modules: Data.Map.Ordered, Data.Set.Ordered
24 other-modules: Data.Map.Util
24 other-modules: Data.Map.Util
25 -- other-extensions:
25 -- other-extensions:
26− build-depends: base >=4 && <5, containers >=0.1 && <0.7
26+ build-depends: base >=4.7 && <5, containers >=0.1 && <0.7
27 -- hs-source-dirs:
27 -- hs-source-dirs:
28 default-language: Haskell98
28 default-language: Haskell98
29 ghc-options: -fno-warn-tabs
29 ghc-options: -fno-warn-tabs