typecheck_info_get_final_info

Fergus Henderson fjh at cs.mu.OZ.AU
Sat May 30 05:23:20 AEST 1998


On 27-May-1998, David Glen JEFFERY <dgj at cs.mu.OZ.AU> wrote:
> Hmmm. After much tracking down, I finally understand my bug now... I'm not 
> quite sure what the solution is, though. Could I get your advice?
> 
> The problem is that typecheck_info_get_final_info goes and renames a whole
> heap of things like the constraint proofs. This shouldn't be a problem since
> the only time there should be variables to get rid of is when you're inferring
> the types, and in that case you end up updating the pred-info with the new
> vartypes, etc etc.
> 
> The reason that this doesn't work for me is that I introduce a pred whose type
> variables are a subset of the type variables of a class/instance declaration.
> In this case, even though we aren't inferring the types, everying still gets
> renamed under my feet.
> 
> Here's two solutions. Which do you think is best?
> 	- When creating the pred, get rid of any unnecessary type vars from the
> 	  varset, and "squash" the tvars down, like we do in
> 	  typecheck_info_get_final_info.
> 	- After typecheck_info_get_final_info, update the var types etc etc in
> 	  the pred-info, even if we aren't inferring the types.
> 
> Whaddyareckon?

Sorry for the late response on this, but I think the first solution
may be slightly better.  The reason is that for every call to
a type class predicate, the type checker will rename the variables
in the called predicate's type apart from the current set of
type variables.  If the number of type vars in the called pred's
typevarset is N, then this operation is O(N), and it also increases
the size of the current typevarset by N.  If there are M calls
to such predicates and inference requires K passes, then
the total cost at least O(N*M*K), probably worse.  Thus keeping
N small is a good idea.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list