X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Futils%2FBag.lhs;h=b2be2c30db697b411231bb63a28b39dfe1741c65;hp=ebc44ac1479975276eb13f755ed0b1b4f974bb3e;hb=f278f0676579f67075033a4f9857715909c4b71e;hpb=ef6e8211dee59eb7fa80a242391b89b52bd57f80 diff --git a/compiler/utils/Bag.lhs b/compiler/utils/Bag.lhs index ebc44ac..b2be2c3 100644 --- a/compiler/utils/Bag.lhs +++ b/compiler/utils/Bag.lhs @@ -18,9 +18,12 @@ module Bag ( mapBagM, mapAndUnzipBagM ) where +#include "Typeable.h" + import Outputable -import Util ( isSingleton ) +import Util +import Data.Data import Data.List ( partition ) infixr 3 `consBag` @@ -188,4 +191,12 @@ bagToList b = foldrBag (:) [] b \begin{code} instance (Outputable a) => Outputable (Bag a) where ppr bag = braces (pprWithCommas ppr (bagToList bag)) + +INSTANCE_TYPEABLE1(Bag,bagTc,"Bag") + +instance Data a => Data (Bag a) where + gfoldl k z b = z listToBag `k` bagToList b -- traverse abstract type abstractly + toConstr _ = abstractConstr $ "Bag("++show (typeOf (undefined::a))++")" + gunfold _ _ = error "gunfold" + dataTypeOf _ = mkNoRepType "Bag" \end{code}