Hello,
Is there any Haskell implementation that supports polymorphic recursion
without the need of annotating the types for defined function by the
programmer?
For example, when I write in Hugs 1.4:
data Tree a = Leaf a | Node (Tree (a,a))
height (Leaf x) = 1
height (Node x) = 1 + (height x)
then Hugs displays message:
ERROR: Type error in function binding
*** term : height
*** type : Tree a -> b
*** does not match : Tree (a,a) -> b
*** because : unification would give infinite type
Or, when I type:
proj x1 x2 x3 = x1
f x = proj x (f True) (f 8)
then the indicated error is:
ERROR: Bool is not an instance of class "Num"
- although both of the examples work after specifying: height :: Tree a -> Int,
f :: a -> a. As I understand, Hugs can only check whether the type given by the
programmer is correct, but it cannot infer the type for polymorphically
recursive function.
--
Tomasz Lukaszewicz [EMAIL PROTECTED]
student of computer sciences at Warsaw University