I can get the file to compile fine. However, when I try to test if the operator is overloaded correctly I get the error message:
*Main> MyFloat (2,3) + MyFloat(3,3) <interactive>:19:15: Ambiguous occurrence `+' It could refer to either `Main.+', defined at problem1.hs:3:16 or `Prelude.+', imported from `Prelude' at problem1.hs:1:1 (and originally defined in `GHC.Num') The code I am using is:
data MyFloat = MyFloat (Int, Int) MyFloat (a, b) + MyFloat (c, d) = ((fromIntegral a)/ (fromIntegral(order a)) * 10^b) Prelude.+ ((fromIntegral c)/ (fromIntegral(order c)) * 10^d) order :: Int -> Int order b | b == 0 = 0 | otherwise = ((ceiling ((logBase 10 (abs (fromIntegral b))))) Prelude.+ 1) Am I misunderstanding how overload operators correctly, or is there a different problem entirely?