I am wondering which mistake the following Haskellcode has!
f :: Fractional a => a -> a -> a
f x y
| x > y = x - y
| otherwise = x + y
call = f 3.5 2.0
I was trying to solve the problem but I couldnt find a solution since 3.5 and 2.0 are floats and that should work with the fractional type.
Well you are comparing the two items
xandy, and this is not exported by theFractionaltypeclass or any of its superclasses, you need to make constrain it toOrdas well:Float,Double, etc. are all instances ofOrdso we can compare the values, so then we get: