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

Ryan Scott ryan.gl.scott at gmail.com
Sat Jul 18 00:58:27 UTC 2015


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).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20150717/af21658c/attachment.html>


More information about the Libraries mailing list