
Thank you both!
The key is that typeclasses are open. You could write a Fractional instance for (a -> a), in which case it would be possible to do _something_ with this code. Would it be useful? Even Haskell can't guarantee that.
Yes, this is important! Thanks.
Now, because we are writing ((+ 1) / 2) and we know that (/) takes two arguments that must be of the same type, we know that the type (Num a') => a' -> a' and the type (Num a'') => a'' have to be the same type, so it must be that a' = a -> a, so now we have:
(+ 1) :: (Num a, Num (a -> a)) => a -> a 2 :: (Num a, Num (a -> a)) => a -> a
I'm still a little confused here. How can passing "2" into "(+ 1) /" cause its type to be mangled? "2" has a type "(Num a) => a". How can the presence of "(+ 1)" force the type of "2" to suddenly accept an argument? How come it doesn't happen the other way around? (Meaning "2" forces the type of "(+ 1)" to become simply "(Num a) => a".) Prelude> :t 2 / (+ 1) 2 / (+ 1) :: (Fractional (a -> a), Num a) => a -> a Thank you, Patrick