Re: [Haskell-cafe] Closed Classes

that g::Int (or, rather, Int->Int)
No, because instances are considered wherever they are defined (as long as they are in _this_ file or an imported one). The point of the example was to show that it is the instances visible in the transitive closure that are considered. Basically the type of g will be g :: A a => a -> a In the end functions have to be called, and it is the ultimate call site for the whole chain of functions where grounded types and concrete values are provided that instance resolution occurs. In the end we can call
g (3::Int) 4
In effect it is the extra parameter (A a) that contains the dictionary for 'A'. We can only choose a dictionary when we know the type of 'a', and we can choose between all instances visible at the call site, not where the function was originally defined. Keean.
participants (1)
-
MR K P SCHUPKE