So in Haskell 98, would the added constraints result in a type error?<br>
<br>
- Job<br><br><div class="gmail_quote">On Tue, Apr 6, 2010 at 5:12 PM, Ross Paterson <span dir="ltr"><<a href="mailto:ross@soi.city.ac.uk">ross@soi.city.ac.uk</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;">
<div class="im">On Tue, Apr 06, 2010 at 03:56:32PM -0400, Job Vranish wrote:<br>
> f _ = undefined<br>
> where<br>
> _ = y :: Int -> Int<br>
><br>
> y x = undefined<br>
> where<br>
> _ = f x<br>
<br>
</div>Because f and y are mutually recursive, their types are inferred together,<br>
so y gets the type Int -> Int (as given), which forces f :: Int -> a.<br>
<br>
If you add the type signature f :: a -> b, you break the cycle: that<br>
type is used in inferring the type of y (namely a -> b), which is then<br>
used in checking the typeof f. Ditto if you add y :: a -> b instead.<br>
(This is not Haskell 98, but the implementations have done this for<br>
years, and it will be in Haskell 2010.)<br>
<div><div></div><div class="h5">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br>