Home:ALL Converter>How to fix Type matching error

How to fix Type matching error

Ask Time:2018-05-07T17:14:36         Author:studyer

Json Formatter

I am writing a function to calculate radius, and the first input is centre of a circle and second is a point from the edge of the circle.

type Coord = (Int,Int)
getRadius :: Coord -> Coord -> Float
getRadius (x0,y0) (x1,y1) = sqrt(sqrX+sqrY)
                             where sqrX = (x1-x0)*(x1-x0)
                                   sqrY = (y1-y0)*(y1-y0)

This is my code but when I compile it , an error shows that "Couldn't match expected type ‘Float’ with actual type ‘Int’. " I think the output should be a float not int . How can I fix this error? thanks

Author:studyer,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/50210726/how-to-fix-type-matching-error
yy