
So in Haskell 98, would the added constraints result in a type error?
- Job
On Tue, Apr 6, 2010 at 5:12 PM, Ross Paterson
On Tue, Apr 06, 2010 at 03:56:32PM -0400, Job Vranish wrote:
f _ = undefined where _ = y :: Int -> Int
y x = undefined where _ = f x
Because f and y are mutually recursive, their types are inferred together, so y gets the type Int -> Int (as given), which forces f :: Int -> a.
If you add the type signature f :: a -> b, you break the cycle: that type is used in inferring the type of y (namely a -> b), which is then used in checking the typeof f. Ditto if you add y :: a -> b instead. (This is not Haskell 98, but the implementations have done this for years, and it will be in Haskell 2010.) _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe