[Haskell-cafe] Newbie "Instance Of Floating Int" Error

Aditya Siram aditya_siram at hotmail.com
Thu Apr 27 22:52:20 EDT 2006

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 
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...

More information about the Haskell-Cafe mailing list