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"><<a href="mailto:simonpj@microsoft.com">simonpj@microsoft.com</a>></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'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'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't infer type (type family + "element" type)<br>
|<br>
| Suppose I have a class C,<br>
|<br>
| > class C a where<br>
| > type E a<br>
| > c :: E a -> a -> a<br>
|<br>
| a datatype T,<br>
|<br>
| > data T a = T a<br>
|<br>
| and an instance of C for T<br>
|<br>
| > instance C (T a) where<br>
| > type E (T a) = a<br>
| > c x (T _) = T x<br>
|<br>
| I would like to write a function such as f<br>
|<br>
| > f t@(T x) = c x t<br>
|<br>
| without a type signature. Unfortunately, I can't because GHC tells me<br>
|<br>
| Couldn't match expected type `t' against inferred type `T (E t)'<br>
| In the second argument of `c', namely `t'<br>
| In the expression: c x t<br>
| In the definition of `f': 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>
| > f :: T a -> T a<br>
|<br>
| (2) Define the class C using an equality constraint<br>
|<br>
| > class C t where<br>
| > type E t<br>
| > c :: (E t ~ e) => e -> t -> t<br>
|<br>
| (3) Define the class C using functional dependencies<br>
|<br>
| > class C t e | t -> e where<br>
| > c :: e -> t -> t<br>
|<br>
| But the real question is why don'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>