
6 Apr
2010
6 Apr
'10
5:12 p.m.
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.)