[Haskell-cafe] Newbie "Instance Of Floating Int" Error
Evan Martin
martine at danga.com
Fri Apr 28 14:11:34 EDT 2006
On 4/28/06, Aditya Siram <aditya_siram at hotmail.com> wrote:
> 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
It's saying that you explicitly gave the function the type "Point ->
Point -> Int" but that it actually has "Point -> Point -> Int".
If you look at the type of sqrt:
Prelude> :t sqrt
sqrt :: (Floating a) => a -> a
You'll see that it returns a floating-point number.
(Also, a minor style point: you should probably get in the habit of
putting a space between the "sqrt" and its arguments. It'll make more
sense as you gain more experience.)
More information about the Haskell-Cafe
mailing list