class Visible a where
toString :: a -> String
size :: a -> Int
intToString :: (Integral t) => t -> String
intToString 0 = "0"
intToString 1 = "1"
intToString 2 = "2"
intToString 3 = "3"
intToString 4 = "4"
intToString 5 = "5"
intToString 6 = "6"
intToString 7 = "7"
intToString 8 = "8"
intToString 9 = "9"
intToString n
| ((div n 10) == 0) = (intToString (mod n 10))
| otherwise = (intToString (div n 10)) ++ (intToString (mod n 10))
Now
instance Visible Int where
toString = intToString
size n = length (toString n)
gives me an error about an ambiguous type variable at the prompt if I type something like (toString 55)
but
instance Visible Integer where
toString = intToString
size n = length (toString n)
does not.
What gives?