I wrote a very simple Haskell program:
main = print $ sum $ map read ["55", "99", "101"]
Given my past experience, I expected to get an "ambiguous type" error, since the signature of sum $ map read [...]
is (Read a, Num a) => a
; Num
is a class and thus cannot itself implement the Show
class. However, the program correctly outputted "255". How was print
able to determine the method of producing the output? (show
also is able to produce the correct result with no error.)