
27 Apr
2006
27 Apr
'06
10:52 p.m.
Hi all, I just started working with Haskell and am having some difficulties with its type system. Here is function that is supposed to calculate the distance between two coordinates: distBetween (x1,y1) (x2,y2) = sqrt((x2-x1)^2 + (y2-y1)^2) I am trying to explictly give it a type signature. Here is what I have tried and the errors generated by Hugs: type Point = (Int,Int) distBetween :: Point -> Point -> Float
ERROR - Type error in explicitly typed binding *** Term : distBetween *** Type : Point -> Point -> Int *** Does not match : Point -> Point -> Float
distBetween :: Point -> Point -> Int
Instance of Floating Int required for definition of distBetween
Any help is appreciated... Deech