Why is Bag's Data instance "broken"?
José Pedro Magalhães
jpm at cs.uu.nl
Thu Sep 20 10:40:16 CEST 2012
On Wed, Aug 29, 2012 at 12:01 PM, Philip Holzenspies
<pkfh at st-andrews.ac.uk>wrote:
> Dear GHCers,
>
> I'm performing traversals over GHC-API results (HsSyn et al). For this
> purpose, I'm using SYB generics.
>
> I found that I couldn't use "ext1Q" for a function with type "Data x =>
> Bag x -> String", i.e. that this function was never applied. The source of
> Bag's instance of the Data class seems to explain why:
>
>
> 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"
>
Btw, where is this instance defined?
Thanks,
Pedro
>
>
> Is there a rationale to not allow gunfolds and to keep toConstr abstract?
> More to the point for my needs, is there a reason to not allow dataCast1
> casting of Bags?
>
> Regards,
> Philip
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20120920/7debd1c4/attachment.htm>
More information about the Glasgow-haskell-users
mailing list