hierarchy-builder icon indicating copy to clipboard operation
hierarchy-builder copied to clipboard

`HB.howto` fails to inform the user about smart factories

Open CohenCyril opened this issue 3 years ago • 3 comments

In the context of mathcomp we use can_type (and others) as a leightweight factory for equality, choice, countability, finiteness by cancellation. HB.howto is not aware of that and fails to inform a user.

Reduced example:

From HB Require Import structures.

HB.mixin Record hasPoint T := { point : T }.
HB.structure Definition Pointed := { T of hasPoint T }.
HB.instance Definition _ := hasPoint.Build unit tt.

(* types which are the image of a pointed type are pointed *)
Definition image_type {T} {iT} (f : T -> iT) := iT.
HB.instance Definition _ (pT : Pointed.type) iT (f : pT -> iT) :=
   hasPoint.Build (image_type f) (f point).

(* HB.howto does not know image_type can be used to make a Pointed.type *)
HB.howto Pointed.type.
HB.instance Definition _ := Pointed.on (image_type (fun _ : unit => true)).

Ideally we would annotate the instance on image_type to flag it as a lightweight factory, for example with an attribute #[light-factory]

CohenCyril avatar Nov 23 '22 18:11 CohenCyril

Also the PcanXXXMixin are not listed but should.

gares avatar Nov 23 '22 21:11 gares