git.iko.soy/typeable/ordered-containers
on master help sign in
five years is a long enough support window
commit4ea50847a77722060539e052d67f7e3ba9501c3f authorDaniel Wagner <me@dmwit.com> dateSun 24 Mar 2019, 11:12 (8 years ago) parent06bd539
3 files changed+8−34
Data/Map/Ordered.hs+4−17 Data/Set/Ordered.hs+3−16 ordered-containers.cabal+1−1
Data/Map/Ordered.hs+4−17
@@ -1,8 +1,5 @@
1−{-# LANGUAGE CPP #-}
1+{-# LANGUAGE DeriveDataTypeable #-}
22{-# LANGUAGE DeriveFunctor #-}
3−#if __GLASGOW_HASKELL__
4−{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-}
5−#endif
63
74-- | An 'OMap' behaves much like a 'Map', with all the same asymptotics, but
85-- also remembers the order that keys were inserted.
@@ -33,6 +30,7 @@ module Data.Map.Ordered
3330
3431import Control.Applicative ((<|>))
3532import Control.Monad (guard)
33+import Data.Data
3634import Data.Foldable (Foldable, foldl', foldMap)
3735import Data.Function (on)
3836import Data.Map (Map)
@@ -40,11 +38,8 @@ import Data.Map.Util (Index, Tag, maxTag, minTag, nextHigherTag, nextLowerTag, r
4038import Prelude hiding (filter, lookup, null)
4139import qualified Data.Map as M
4240
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)
4843
4944-- | Values are produced in insertion order, not key order.
5045instance 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`
5348instance ( Show k, Show v) => Show (OMap k v) where showsPrec = showsPrecList assocs
5449instance (Ord k, Read k, Read v) => Read (OMap k v) where readsPrec = readsPrecList fromList
5550
56−#if __GLASGOW_HASKELL__
57−# if __GLASGOW_HASKELL__ >= 708
58−deriving instance Typeable OMap
59−# else
60−deriving instance Typeable2 OMap
61−# endif
62−
6351-- This instance preserves data abstraction at the cost of inefficiency.
6452-- We provide limited reflection services for the sake of data abstraction.
6553
@@ -77,7 +65,6 @@ fromListConstr = mkConstr oMapDataType "fromList" [] Prefix
7765
7866oMapDataType :: DataType
7967oMapDataType = mkDataType "Data.Map.Ordered.Map" [fromListConstr]
80−#endif
8168
8269infixr 5 <|, |< -- copy :
8370infixl 5 >|, |>
Data/Set/Ordered.hs+3−16
@@ -1,7 +1,4 @@
1−{-# LANGUAGE CPP #-}
2−#if __GLASGOW_HASKELL__
3−{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-}
4−#endif
1+{-# LANGUAGE DeriveDataTypeable #-}
52
63-- | An 'OSet' behaves much like a 'Set', with all the same asymptotics, but
74-- also remembers the order that values were inserted.
@@ -30,6 +27,7 @@ module Data.Set.Ordered
3027 ) where
3128
3229import Control.Monad (guard)
30+import Data.Data
3331import Data.Foldable (Foldable, foldl', foldMap, foldr, toList)
3432import Data.Function (on)
3533import Data.Map (Map)
@@ -38,11 +36,8 @@ import Data.Set (Set) -- so the haddocks link to the right place
3836import Prelude hiding (filter, foldr, lookup, null)
3937import qualified Data.Map as M
4038
41−#if __GLASGOW_HASKELL__
42−import Data.Data
43−#endif
44−
4539data OSet a = OSet !(Map a Tag) !(Map Tag a)
40+ deriving Typeable
4641
4742-- | Values appear in insertion order, not ascending order.
4843instance 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
5146instance Show a => Show (OSet a) where showsPrec = showsPrecList toList
5247instance (Ord a, Read a) => Read (OSet a) where readsPrec = readsPrecList fromList
5348
54−#if __GLASGOW_HASKELL__
55−# if __GLASGOW_HASKELL__ >= 708
56−deriving instance Typeable OSet
57−# else
58−deriving instance Typeable1 OSet
59−# endif
60−
6149-- This instance preserves data abstraction at the cost of inefficiency.
6250-- We provide limited reflection services for the sake of data abstraction.
6351
@@ -75,7 +63,6 @@ fromListConstr = mkConstr oSetDataType "fromList" [] Prefix
7563
7664oSetDataType :: DataType
7765oSetDataType = mkDataType "Data.Set.Ordered.Set" [fromListConstr]
78−#endif
7966
8067infixr 5 <|, |< -- copy :
8168infixl 5 >|, |>
ordered-containers.cabal+1−1
@@ -23,7 +23,7 @@ library
2323 exposed-modules: Data.Map.Ordered, Data.Set.Ordered
2424 other-modules: Data.Map.Util
2525 -- 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
2727 -- hs-source-dirs:
2828 default-language: Haskell98
2929 ghc-options: -fno-warn-tabs