From: Duncan C. <dun...@wo...> - 2007-01-08 13:26:01
|
Thu Dec 28 15:17:31 PST 2006 Duncan Coutts <du...@co...> * Add Data.Map compat module to allow building with ghc 6.2 hunk ./Makefile.am 157 + tools/c2hs/base/general/Map.hs \ hunk ./tools/c2hs/base/general/Binary.hs 59 -import Data.Map (Map) -import qualified Data.Map as Map +import Map (Map) +import qualified Map as Map addfile ./tools/c2hs/base/general/Map.hs hunk ./tools/c2hs/base/general/Map.hs 1 +{-# OPTIONS -cpp #-} + +module Map ( + Map, + empty, singleton, + lookup, findWithDefault, + insert, + union, unionWith, + map, + fromList, toList +) where + +import Prelude hiding (lookup, map) + +#if __GLASGOW_HASKELL__ >= 603 || !__GLASGOW_HASKELL__ +import Data.Map +#else +import Data.FiniteMap + +type Map k a = FiniteMap k a + +instance Functor (FiniteMap k) where + fmap f = mapFM (const f) + +empty :: Map k a +empty = emptyFM + +singleton :: k -> a -> Map k a +singleton = unitFM + +lookup :: Ord k => k -> Map k a -> Maybe a +lookup = flip lookupFM + +findWithDefault :: Ord k => a -> k -> Map k a -> a +findWithDefault a k m = lookupWithDefaultFM m a k + +insert :: Ord k => k -> a -> Map k a -> Map k a +insert k a m = addToFM m k a + +insertWith :: Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a +insertWith c k a m = addToFM_C (flip c) m k a + +union :: Ord k => Map k a -> Map k a -> Map k a +union = flip plusFM + +unionWith :: Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a +unionWith c l r = plusFM_C (flip c) r l + +map :: (a -> b) -> Map k a -> Map k b +map f = mapFM (\_ -> f) + +fromList :: Ord k => [(k,a)] -> Map k a +fromList = listToFM + +toList :: Map k a -> [(k, a)] +toList = fmToList + +#endif hunk ./tools/c2hs/base/syms/Attributes.hs 97 -import Data.Map (Map) -import qualified Data.Map as Map (fromList, toList, insert, +import Map (Map) +import qualified Map as Map (fromList, toList, insert, hunk ./tools/c2hs/base/syms/NameSpaces.hs 45 -import Data.Map (Map) -import qualified Data.Map as Map (empty, insert, lookup, toList) +import Map (Map) +import qualified Map as Map (empty, insert, lookup, toList) hunk ./tools/c2hs/base/syntax/Parsers.hs 86 -import Data.Map (Map) -import qualified Data.Map as Map (singleton, unionWith, map, lookup, toList) +import Map (Map) +import qualified Map as Map (singleton, unionWith, map, lookup, toList) hunk ./tools/c2hs/gen/GBMonad.hs 83 -import Data.Map (Map) -import qualified Data.Map as Map (empty, insert, lookup, fromList, toList, union) +import Map (Map) +import qualified Map as Map (empty, insert, lookup, fromList, toList, union) |