X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Data%2FFiniteMap.hs;h=d9279171c348e0f4758194b6263ddae46f36f017;hb=0d6c1599c246100deb2fa54315811ed94d1a300c;hp=f8d0826a6c61e1f9a8be4a30a64c44347d41b8d6;hpb=b72cb4f4e104ab0c64feb46ca4d3d8187c90dd28;p=ghc-base.git diff --git a/Data/FiniteMap.hs b/Data/FiniteMap.hs index f8d0826..d927917 100644 --- a/Data/FiniteMap.hs +++ b/Data/FiniteMap.hs @@ -93,6 +93,9 @@ import Prelude -- necessary to get dependencies right import Data.Maybe ( isJust ) #ifdef __GLASGOW_HASKELL__ import GHC.Base +import Data.Typeable +import Data.Generics.Basics +import Data.Generics.Instances #endif #ifdef __HADDOCK__ @@ -121,6 +124,7 @@ import Bag ( foldBag ) #endif /* not GHC */ + -- --------------------------------------------------------------------------- -- The signature of the module @@ -289,6 +293,23 @@ instance (Show k, Show e) => Show (FiniteMap k e) where instance Functor (FiniteMap k) where fmap f = mapFM (const f) +#if __GLASGOW_HASKELL__ + +#include "Typeable.h" +INSTANCE_TYPEABLE2(FiniteMap,arrayTc,"FiniteMap") + +-- This instance preserves data abstraction at the cost of inefficiency. +-- We omit reflection services for the sake of data abstraction. + +instance (Data a, Data b, Ord a) => Data (FiniteMap a b) where + gfoldl f z fm = z listToFM `f` (fmToList fm) + toConstr _ = error "toConstr" + gunfold _ _ = error "gunfold" + dataTypeOf _ = mkNorepType "Data.Array.Array" + +#endif + + -- --------------------------------------------------------------------------- -- Adding to and deleting from @FiniteMaps@