@@ -1,8 +1,5 @@
1−{-# LANGUAGE CPP #-}
1+{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE DeriveFunctor #-}
2{-# LANGUAGE DeriveFunctor #-}
3−#if __GLASGOW_HASKELL__
4−{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-}
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
34import Control.Applicative ((<|>))
31import Control.Applicative ((<|>))
35import Control.Monad (guard)
32import Control.Monad (guard)
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
43−#if __GLASGOW_HASKELL__
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)
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
56−#if __GLASGOW_HASKELL__
57−# if __GLASGOW_HASKELL__ >= 708
58−deriving instance Typeable OMap
60−deriving instance Typeable2 OMap
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.
@@ -77,7 +65,6 @@ fromListConstr = mkConstr oMapDataType "fromList" [] Prefix
78oMapDataType :: DataType
66oMapDataType :: DataType
79oMapDataType = mkDataType "Data.Map.Ordered.Map" [fromListConstr]
67oMapDataType = mkDataType "Data.Map.Ordered.Map" [fromListConstr]
82infixr 5 <|, |< -- copy :
69infixr 5 <|, |< -- copy :
83infixl 5 >|, |>
70infixl 5 >|, |>