3
$\begingroup$

It's basically this question but about classes.

Imagine I want to do this:

Class CMonoid :=
  { A : Type
  ; operator : A -> A -> A
  ; property : a <> b = b <> a (* note the use of <> *)
  ; ...
  }

Notation "a <> b" := operator a b. (* too late! *)

Where can I insert the notation definition so I can write the above?

This may look like an overkill for notation, but that's because it's a simplified example. The real use case is a very long definition, and I want to use notation to simplify it.

$\endgroup$

1 Answer 1

4
$\begingroup$

This seems to work:

Reserved Notation "a <> b"
  (at level 70, no associativity).

Class CMonoid :=
  { A : Type
  ; operator : A -> A -> A
      where "a <> b" := (operator a b)
  ; property : forall (a b : A),
      (a <> b) = (b <> a)
  }.

Source: https://github.com/coq/coq/issues/7187

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.