[Haskell-cafe] Closed Classes

MR K P SCHUPKE k.schupke at imperial.ac.uk
Fri Aug 13 04:38:21 EDT 2004

>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)

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.


More information about the Haskell-Cafe mailing list