<div dir="ltr"><div><div>There is an example at <a href="http://lpaste.net/164532">http://lpaste.net/164532</a> (attached as well)<br><br></div>The derived Data instance fails with <br><br>/home/alanz/Example.hs:19:19:<br>    Illegal type synonym family application in instance:<br>      NameOrRdrName id<br>    In the stand-alone deriving instance for ‘Data (NameOrRdrName id)’<br><br></div><div>And how would an instance for Outputable be defined in terms of the existing ones?<br><br></div>Alan<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 25, 2016 at 8:03 PM, Simon Peyton Jones <span dir="ltr"><<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div link="blue" vlink="purple" lang="EN-GB">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Can you give a small example? Certainly any instance like<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">                instance Data x => Data (F x)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">is not allowed, of course, if F is a type function. It’s like not allowing<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">f (g x) = x<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">in the term language.  Only constructors in patterns!<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><br>
S<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" lang="EN-US">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" lang="EN-US"> ghc-devs [mailto:<a href="mailto:ghc-devs-bounces@haskell.org" target="_blank">ghc-devs-bounces@haskell.org</a>]
<b>On Behalf Of </b>Alan & Kim Zimmerman<br>
<b>Sent:</b> 25 May 2016 18:39<br>
<b>To:</b> <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Subject:</b> instances for closed type families<u></u><u></u></span></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm">
I am working on <a href="https://ghc.haskell.org/trac/ghc/ticket/12105" target="_blank">
https://ghc.haskell.org/trac/ghc/ticket/12105</a>, and have a type to ensure that the `HsMatchContext` has either a `RdrName` or a `Name`, not an `Id`.<br>
<br>
type family NameOrRdrName id where<br>
  NameOrRdrName Id      = Name<br>
  NameOrRdrName Name    = Name<br>
  NameOrRdrName RdrName = RdrName<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm">
Is there any way to declare `Data` and `OutputableBndr` instances for this?<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm">
Without it I am having to do something like<br>
<br>
instance (OutputableBndr name, OutputableBndr (NameOrRdrName name))<br>
         => Outputable (HsDecl name) where<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm">
which requires UndecidableInstances.<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm">
I get<br>
<br>
compiler/hsSyn/PlaceHolder.hs:114:19:<br>
    Illegal type synonym family application in instance:<br>
      NameOrRdrName id<br>
    In the stand-alone deriving instance for ‘Data (NameOrRdrName id)’<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm">
for the parameterised version and<br>
<br>
compiler/hsSyn/PlaceHolder.hs:115:19:<br>
    Illegal type synonym family application in instance:<br>
      NameOrRdrName RdrName<br>
    In the stand-alone deriving instance for<br>
      ‘Data (NameOrRdrName RdrName)’<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm">
for the one specific to `RdrName`.<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
Regards<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
  Alan<u></u><u></u></p>
</div>
</div></div></div>
</div>
</div>

</blockquote></div><br></div>