[project @ 2005-01-19 22:33:32 by ralf]
[haskell-directory.git] / Data / IntMap.hs
index 41d9ba2..46c6bee 100644 (file)
@@ -147,6 +147,11 @@ import List (nub,sort)
 import qualified List
 -}  
 
+#if __GLASGOW_HASKELL__
+import Data.Generics.Basics
+import Data.Generics.Instances
+#endif
+
 #if __GLASGOW_HASKELL__ >= 503
 import GHC.Word
 import GHC.Exts ( Word(..), Int(..), shiftRL# )
@@ -205,6 +210,23 @@ type Mask   = Int
 type Key    = Int
 
 {--------------------------------------------------------------------
+  A Data instance  
+--------------------------------------------------------------------}
+
+#if __GLASGOW_HASKELL__
+
+-- This instance preserves data abstraction at the cost of inefficiency.
+-- We omit reflection services for the sake of data abstraction.
+
+instance Data a => Data (IntMap a) where
+  gfoldl f z im = z fromList `f` (toList im)
+  toConstr _    = error "toConstr"
+  gunfold _ _   = error "gunfold"
+  dataTypeOf _  = mkNorepType "Data.IntMap.IntMap"
+
+#endif
+
+{--------------------------------------------------------------------
   Query
 --------------------------------------------------------------------}
 -- | /O(1)/. Is the map empty?