[project @ 2005-01-19 22:33:32 by ralf]
[ghc-base.git] / Data / Map.hs
index 4635bf4..9e78149 100644 (file)
@@ -161,6 +161,11 @@ import Debug.QuickCheck
 import List(nub,sort)    
 -}
 
+#if __GLASGOW_HASKELL__
+import Data.Generics.Basics
+import Data.Generics.Instances
+#endif
+
 {--------------------------------------------------------------------
   Operators
 --------------------------------------------------------------------}
@@ -184,6 +189,23 @@ data Map k a  = Tip
 type Size     = 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 k, Data a, Ord k) => Data (Map k a) where
+  gfoldl f z map = z fromList `f` (toList map)
+  toConstr _     = error "toConstr"
+  gunfold _ _    = error "gunfold"
+  dataTypeOf _   = mkNorepType "Data.Map.Map"
+
+#endif
+
+{--------------------------------------------------------------------
   Query
 --------------------------------------------------------------------}
 -- | /O(1)/. Is the map empty?