<div dir="ltr"><div>> The proposed instance is overconstrained. You only need Typeable for the second argument of Const (because it is phantom).<br><br>It's a phantom type, but the Data constraint is necessary because the way deriving Data works. If  You can read this [1] for an explanation behind this design decision. Essentially, if GHC sees that a datatype has two type parameters of kind *, then it generates a definition for the dataCast2 method, which allows for a higher-order version of the cast function. But implementing dataCast2 requires that both type parameters be Data instances.<br><br></div><div>A separate question would be whether implementing dataCast2 could be done without these Data constraints (and thus allowing the second type parameter to only be an instance of Typeable, rather than Data). But that is outside my area of expertise; I'd need someone more knowledgeable in the arts of Data.Data than I.<br><br>For now, I am proposing what GHC currently considers to be a canonical Data instance for Const. We can revisit the exact instance context details later if need be.<br></div><div><br></div>Ryan S.<br>-----<br>[1] <a href="https://ghc.haskell.org/trac/ghc/ticket/4028">https://ghc.haskell.org/trac/ghc/ticket/4028</a><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 2, 2016 at 3:16 PM, Index Int <span dir="ltr"><<a href="mailto:vlad.z.4096@gmail.com" target="_blank">vlad.z.4096@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The proposed instance is overconstrained. You only need Typeable for<br>
the second argument of Const (because it is phantom).<br>
<div class="HOEnZb"><div class="h5"><br>
On Wed, Nov 2, 2016 at 7:05 PM, Edward Kmett <<a href="mailto:ekmett@gmail.com">ekmett@gmail.com</a>> wrote:<br>
> Definitely an oversight.<br>
><br>
> On Wed, Nov 2, 2016 at 11:40 AM, Ryan Scott <<a href="mailto:ryan.gl.scott@gmail.com">ryan.gl.scott@gmail.com</a>> wrote:<br>
>><br>
>> GHC Trac #12438 [1] exists because there's no Data instance for Const<br>
>> in base. I found this quite surprising, since we have Data instances<br>
>> for just about every other type combinator out there (Identity, Sum,<br>
>> Product, Compose, etc.), but not for Const. The fix for #12438 would<br>
>> be quite simple: I propose we add<br>
>><br>
>>     deriving instance (Data a, Data b) => Data (Const a b)<br>
>><br>
>> to Data.Data in base. Any objections?<br>
>><br>
>> Ryan S.<br>
>> -----<br>
>> [1] <a href="https://ghc.haskell.org/trac/ghc/ticket/12438" rel="noreferrer" target="_blank">https://ghc.haskell.org/trac/<wbr>ghc/ticket/12438</a><br>
>> ______________________________<wbr>_________________<br>
>> Libraries mailing list<br>
>> <a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
>> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/libraries</a><br>
><br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> Libraries mailing list<br>
> <a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/libraries</a><br>
><br>
</div></div></blockquote></div><br></div>