[m-rev.] for review: type_spec_constrained_preds

Julien Fischer jfischer at opturion.com
Wed Feb 7 13:58:22 AEDT 2024


On Tue, 6 Feb 2024, Zoltan Somogyi wrote:

> Implement type_spec_constrained_preds pragmas.

...

> compiler/handl_options.m:

s/handl/handle/

...

> compiler/prog_type_unify.m:
>     Fix indentation.
> 
> vim/syntax/mercury.vim:
>     List the new pragma name.

You've already listed this change above.

...


> diff --git a/compiler/add_pragma_type_spec.m b/compiler/add_pragma_type_spec.m
> index 1e1ac5bd8..d9f9c4507 100644
> --- a/compiler/add_pragma_type_spec.m
> +++ b/compiler/add_pragma_type_spec.m

...

> @@ -50,11 +61,1043 @@

...

> +
> +add_pragma_type_spec_constr(ProgressStream, TypeSpecConstr,


...

> +%---------------------%
> +
> +    % Values of this type represent the set of typeclass constraints
> +    % we want to specialize. Each class_id in here will correspond
> +    % either to a constraint in a type_spec_constrained_preds pragma,
> +    % one its superclasses, or one of *their* superclasses, and so on.
> +    % We may be on the lookout for more than one instance of a class.

may or must?

> diff --git a/compiler/module_qual.qualify_items.m b/compiler/module_qual.qualify_items.m
> index 9f3a763f2..8461757b5 100644
> --- a/compiler/module_qual.qualify_items.m
> +++ b/compiler/module_qual.qualify_items.m

...


> @@ -1613,6 +1680,30 @@ qualify_instance_method(DefaultModuleName, InstanceMethod0, InstanceMethod) :-
>
>  module_qualify_item_decl_pragma(InInt, Pragma0, Pragma, !Info, !Specs) :-
>      (
> +        Pragma0 = decl_pragma_type_spec_constr(TypeSpecConstrInfo0),
> +        TypeSpecConstrInfo0 = decl_pragma_type_spec_constr_info(ModuleName,
> +            OoMConstraints0, ApplyToSupers, OoMSubsts0, TVarSet, Items,
> +            Context, SeqNum),
> +        % XXX

What's the XXX for?

> +        ConstraintErrorContext = mqcec_type_spec_constr(Context, ModuleName),
> +        OoMConstraints0 = one_or_more(HeadConstraint0, TailConstraints0),
> +        qualify_var_or_ground_constraint(InInt, ConstraintErrorContext,
> +            HeadConstraint0, HeadConstraint, !Info, !Specs),
> +        qualify_var_or_ground_constraint_list(InInt, ConstraintErrorContext,
> +            TailConstraints0, TailConstraints, !Info, !Specs),
> +        OoMConstraints = one_or_more(HeadConstraint, TailConstraints),
> +        ErrorContext = mqec_pragma_decl(Context, Pragma0),
> +        OoMSubsts0 = one_or_more(HeadSubst0, TailSubsts0),
> +        qualify_type_subst(InInt, ErrorContext,
> +            HeadSubst0, HeadSubst, !Info, !Specs),
> +        list.map_foldl2(qualify_type_subst(InInt, ErrorContext),
> +            TailSubsts0, TailSubsts, !Info, !Specs),
> +        OoMSubsts = one_or_more(HeadSubst, TailSubsts),
> +        TypeSpecConstrInfo = decl_pragma_type_spec_constr_info(ModuleName,
> +            OoMConstraints, ApplyToSupers, OoMSubsts, TVarSet, Items,
> +            Context, SeqNum),
> +        Pragma = decl_pragma_type_spec_constr(TypeSpecConstrInfo)
> +    ;
>          Pragma0 = decl_pragma_type_spec(TypeSpecInfo0),
>          TypeSpecInfo0 = decl_pragma_type_spec_info(PFUMM0, PredName,
>              SpecPredName, Subst0, TVarSet, Items, Context, SeqNum),

That looks fine otherwise.

Julien.


More information about the reviews mailing list