Re: More general Generic and Data instances for Data.Proxy.Proxy?

It does seem unnecessary. The Data instance for Proxy is manually written in Data.Data: proxyConstr :: ConstrproxyConstr = mkConstr proxyDataType "Proxy" [] PrefixproxyDataType :: DataTypeproxyDataType = mkDataType "Data.Proxy.Proxy" [proxyConstr] instance (Data t) => Data (Proxy t) where gfoldl _ z Proxy = z Proxy toConstr Proxy = proxyConstr gunfold _ z c = case constrIndex c of 1 -> z Proxy _ -> error "Data.Data.gunfold(Proxy)" dataTypeOf _ = proxyDataType dataCast1 f = gcast1 f If dataCast1 weren't defined to be gcast1, then that instance would only require a Typeable t constraint, which would make it polykinded. To be honest, I'm not sure why gcast1 requires a Data t constraint (I don't use Data that often, so hopefully someone more knowledgeable than me can answer this).

No time to go into details right now, unfortunately, but that is required
for the extension mechanism of ext/ext1 to work properly.
Cheers,
Pedro
On 18 Jul 2015 2:58 am, "Ryan Scott"
It does seem unnecessary. The Data instance for Proxy is manually written in Data.Data:
proxyConstr :: ConstrproxyConstr = mkConstr proxyDataType "Proxy" [] PrefixproxyDataType :: DataTypeproxyDataType = mkDataType "Data.Proxy.Proxy" [proxyConstr]
instance (Data t) => Data (Proxy t) where gfoldl _ z Proxy = z Proxy toConstr Proxy = proxyConstr gunfold _ z c = case constrIndex c of 1 -> z Proxy _ -> error "Data.Data.gunfold(Proxy)" dataTypeOf _ = proxyDataType dataCast1 f = gcast1 f
If dataCast1 weren't defined to be gcast1, then that instance would only require a Typeable t constraint, which would make it polykinded. To be honest, I'm not sure why gcast1 requires a Data t constraint (I don't use Data that often, so hopefully someone more knowledgeable than me can answer this).
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

See Scrap more boilerplate: reflection, zips, and generalised casts by Ralf
Lämmel and Simon Peyton Jones
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.114.6907&rep=rep1&type=pdf
for
why gcast1 and dataCast1 exist as they do.
On Fri, Jul 17, 2015 at 8:58 PM, Ryan Scott
It does seem unnecessary. The Data instance for Proxy is manually written in Data.Data:
proxyConstr :: ConstrproxyConstr = mkConstr proxyDataType "Proxy" [] PrefixproxyDataType :: DataTypeproxyDataType = mkDataType "Data.Proxy.Proxy" [proxyConstr]
instance (Data t) => Data (Proxy t) where gfoldl _ z Proxy = z Proxy toConstr Proxy = proxyConstr gunfold _ z c = case constrIndex c of 1 -> z Proxy _ -> error "Data.Data.gunfold(Proxy)" dataTypeOf _ = proxyDataType dataCast1 f = gcast1 f
If dataCast1 weren't defined to be gcast1, then that instance would only require a Typeable t constraint, which would make it polykinded. To be honest, I'm not sure why gcast1 requires a Data t constraint (I don't use Data that often, so hopefully someone more knowledgeable than me can answer this).
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
participants (3)
-
Edward Kmett
-
José Pedro Magalhães
-
Ryan Scott