Done: <a href="http://hackage.haskell.org/trac/ghc/ticket/3826">http://hackage.haskell.org/trac/ghc/ticket/3826</a><br><br>Regards,<br>Sean<br><br><div class="gmail_quote">On Tue, Jan 19, 2010 at 11:15, Simon Peyton-Jones <span dir="ltr">&lt;<a href="mailto:simonpj@microsoft.com">simonpj@microsoft.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Looks like a bug to me!  I am currently elbows-deep in re-engineering GHC&#39;s entire constraint generation and solving mechanism, which will, I hope, simply solve your problem.<br>


<br>
But meanwhile can I ask a favour: submit a Trac report with the offending code in reproducible form? Then I&#39;ll be sure to test the new code against all such tickets.<br>
<br>
Thanks<br>
<br>
Simon<br>
<div><div></div><div class="h5"><br>
| -----Original Message-----<br>
| From: <a href="mailto:glasgow-haskell-users-bounces@haskell.org">glasgow-haskell-users-bounces@haskell.org</a> [mailto:<a href="mailto:glasgow-haskell-users-">glasgow-haskell-users-</a><br>
| <a href="mailto:bounces@haskell.org">bounces@haskell.org</a>] On Behalf Of Sean Leather<br>
| Sent: 18 January 2010 16:59<br>
| To: GHC Users List<br>
| Subject: Can&#39;t infer type (type family + &quot;element&quot; type)<br>
|<br>
| Suppose I have a class C,<br>
|<br>
| &gt; class C a where<br>
| &gt;   type E a<br>
| &gt;   c :: E a -&gt; a -&gt; a<br>
|<br>
| a datatype T,<br>
|<br>
| &gt; data T a = T a<br>
|<br>
| and an instance of C for T<br>
|<br>
| &gt; instance C (T a) where<br>
| &gt;   type E (T a) = a<br>
| &gt;   c x (T _) = T x<br>
|<br>
| I would like to write a function such as f<br>
|<br>
| &gt; f t@(T x) = c x t<br>
|<br>
| without a type signature. Unfortunately, I can&#39;t because GHC tells me<br>
|<br>
|     Couldn&#39;t match expected type `t&#39; against inferred type `T (E t)&#39;<br>
|     In the second argument of `c&#39;, namely `t&#39;<br>
|     In the expression: c x t<br>
|     In the definition of `f&#39;: f (t@(T x)) = c x t<br>
|<br>
| There are at least three possible ways to write the above code such<br>
| that it works.<br>
|<br>
| (1) Give a type signature for f<br>
|<br>
| &gt; f :: T a -&gt; T a<br>
|<br>
| (2) Define the class C using an equality constraint<br>
|<br>
| &gt; class C t where<br>
| &gt;   type E t<br>
| &gt;   c :: (E t ~ e) =&gt; e -&gt; t -&gt; t<br>
|<br>
| (3) Define the class C using functional dependencies<br>
|<br>
| &gt; class C t e | t -&gt; e where<br>
| &gt;   c :: e -&gt; t -&gt; t<br>
|<br>
| But the real question is why don&#39;t I get a type for f?<br>
|<br>
| This has been tested in GHC 6.10.1 and 6.12.1.<br>
|<br>
| Thanks,<br>
| Sean<br>
</div></div>| _______________________________________________<br>
| Glasgow-haskell-users mailing list<br>
| <a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.org</a><br>
| <a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
<br>
</blockquote></div><br>