[m-dev.] diff: typeclasses (round 2) [2/4]

Fergus Henderson fjh at cs.mu.oz.au
Thu Dec 18 20:31:34 AEDT 1997


On 18-Dec-1997, David Glen JEFFERY <dgj at cs.mu.oz.au> wrote:
> --- compiler/det_analysis.m	Wed Dec 17 13:25:43 1997
> +++ /home/pgrad/dgj/mer/work/mercury/compiler/det_analysis.m	Tue Dec  2 18:16:44 1997
> -			% ignore class members
> -		list__member(request(class_method), Markers)
> +			% ignore class members, since their bodies are filled
> +			% in after this pass, and the body is gauranteed to
> +			% be determinism-correct. Determinism correctness of
> +			% the methods in an instance declaration are check
> +			% separately in check_typeclass.m

s/are check/is checked/

> --- compiler/equiv_type.m	Thu Dec 18 15:37:50 1997
> +++ /home/pgrad/dgj/mer/work/mercury/compiler/equiv_type.m	Tue Dec  9 18:39:57 1997
...
>  equiv_type__replace_in_item(
> -		func(VarSet0, PredName, TypesAndModes0, RetTypeAndMode0, 
> -			Det, Cond, Purity, ClassContext),
> -		EqvMap,
> -		func(VarSet, PredName, TypesAndModes, RetTypeAndMode,
> -			Det, Cond, Purity, ClassContext),
> -		no) :-
> +			func(VarSet0, PredName, TypesAndModes0, 
> +				RetTypeAndMode0, Det, Cond, Purity,
> +				ClassContext),
> +			EqvMap,
> +			func(VarSet, PredName, TypesAndModes
> +				, RetTypeAndMode, Det, Cond, Purity,

Please put the commas in the usual place, not at the start of a line.

> --- compiler/lambda.m	Thu Dec 18 15:53:45 1997
> +++ /home/pgrad/dgj/mer/work/mercury/compiler/lambda.m	Tue Dec  2 16:43:17 1997
> @@ -28,6 +28,11 @@
>  %
>  %	:- pred '__LambdaGoal__1'(int::in, int::out) is nondet.
>  %	'__LambdaGoal__1'(X, Y) :- q(Y, X).
> +%
> +%
> +%
> +%	Note: Support for lambda expressions which involve class constraints
> +%	      is not yet complete.

What still needs to be done?

> --- compiler/make_hlds.m	Thu Dec 18 17:49:10 1997
> +++ /home/pgrad/dgj/mer/work/mercury/compiler/make_hlds.m	Thu Dec 18 17:47:16 1997
> -	ClassContext=[],
> +	ClassContext  = [],

s/  / /
  ^^ ^

typecheck.m:
> +				% Arguably, we could do context reduction at
> +				% a different point. See the paper:
> +				% "Type class: an exploration of the design
> +				% space", S.P. Jones, M. Jones 1997.
> +				% for a discussion of some of the issues.

Is the paper really called "Type class: ...",
not "Type classes: ..."?

> +:- type cons_type_info 
> +	---> cons_type_info(
> +			tvarset, 
> +			type, 
> +			list(type), 
> +			list(class_constraint)
> +		).

Some comments here would be helpful.

> +apply_class_rules_2([], Constraints, _, _, Proofs, Proofs, Constraints, no).
> +apply_class_rules_2([C|Cs], AllConstraints, ClassTable, TVarSet,
> +		Proofs0, Proofs, Constraints, Changed) :-
> +	C = constraint(ClassName, Types),
> +	list__length(Types, Arity),
>  	ClassId = class_id(ClassName, Arity),
>  	map__lookup(ClassTable, ClassId, ClassDefn),
> -	term__apply_rec_substitution_to_list(Types0, Bindings, Types),
>  	ClassDefn = hlds_class_defn(ParentClassConstraints0, ClassVars,
> -		_ClassInterface, ClassVarset),
> +		_ClassInterface, ClassVarset, _TermContext),
>  	term__var_list_to_term_list(ClassVars, ClassTypes),
> -		% XXX Can we really ignore _NewTypeNames?
> -	varset__merge_subst(TypeNames, ClassVarset, _NewTypeNames, RenameSubst),
> +		% XXX Can we really ignore _NewTVarSet?
> +	varset__merge_subst(TVarSet, ClassVarset, NewTVarSet, RenameSubst),

I'm still a bit worried by this XXX.


Apart from the stuff mentioned above, those changes look fine.


So, it looks like this stuff is just about ready to be committed.
There are still some important things outstanding, namely

	- documentation
	- test cases
	- specialization of class method calls if the type is known
	- support for type inference

but I think that even though all of these are pretty crucial it is
probably worth committing now so that the rest of us can give it a
bit of a shake-out while you work on those.

Please post a final diff (with respect to the current CVS main branch)
when you commit.

Cheers,
	Fergus.

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