<div dir="ltr"><div class="gmail_default" style="font-size:small">Is there a way to connect this to template-haskell or haskell-src-exts code?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 6, 2016 at 4:40 PM, Edward Z. Yang <span dir="ltr"><<a href="mailto:ezyang@mit.edu" target="_blank">ezyang@mit.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks Simon, that has all the ingredients I need.<br>
<br>
I wrote some more docs for the function: <a href="https://phabricator.haskell.org/D2180" rel="noreferrer" target="_blank">https://phabricator.haskell.org/D2180</a><br>
<br>
Edward<br>
<br>
Excerpts from Simon Peyton Jones's message of 2016-05-06 02:05:31 -0700:<br>
<div class="HOEnZb"><div class="h5">> You probably want a variant on TcDeriv.simplifyDeriv, shorn of its complex error reporting.<br>
><br>
> Simon<br>
><br>
> |  -----Original Message-----<br>
> |  From: ghc-devs [mailto:<a href="mailto:ghc-devs-bounces@haskell.org">ghc-devs-bounces@haskell.org</a>] On Behalf Of<br>
> |  Edward Z. Yang<br>
> |  Sent: 06 May 2016 00:21<br>
> |  To: ghc-devs <<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a>><br>
> |  Subject: Determining if an instance is provided by the environment<br>
> |<br>
> |  Hello all,<br>
> |<br>
> |  Suppose I have a ClsInst from typechecking the following instance<br>
> |  declaration:<br>
> |<br>
> |      instance Show [Char] -- i.e. String<br>
> |<br>
> |  I'd now like to answer the question: "Is this instance 'provided'<br>
> |  by the instance environment?"  For example, this instance is provided<br>
> |  given that I have these two instances in the environment:<br>
> |<br>
> |      instance Show a => Show [a] -- (1)<br>
> |      instance Show Char          -- (2)<br>
> |<br>
> |  However, if I have just instance (1) in the environment, it's not<br>
> |  provided (and if you tried to use show "foo", you'd get the error that<br>
> |  Char is not an instance of Show.)<br>
> |<br>
> |  Is there are convenient way to do this from TcM?  With 'tcMatchTys'<br>
> |  and I can easily test if there is some instance in the environment<br>
> |  which *matches* my instance head (e.g., Show [a] matches Show [Char])<br>
> |  but this doesn't tell me if all the resulting constraints are solvable.<br>
> |<br>
> |  Thanks,<br>
> |  Edward<br>
> |  _______________________________________________<br>
> |  ghc-devs mailing list<br>
> |  <a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
> |  <a href="https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fmail.ha" rel="noreferrer" target="_blank">https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fmail.ha</a><br>
> |  <a href="http://skell.org" rel="noreferrer" target="_blank">skell.org</a>%2fcgi-bin%2fmailman%2flistinfo%2fghc-<br>
> |  devs&data=01%7c01%7csimonpj%<a href="http://40064d.mgd.microsoft.com" rel="noreferrer" target="_blank">40064d.mgd.microsoft.com</a>%7c8c304d9b355244c6<br>
> |  ee7208d3753be740%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=iWdrnb6hC<br>
> |  8pexyVkWNG22G%2fgdO10tCBy8nuCxhnO0M8%3d<br>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</div></div></blockquote></div><br></div>