#[export] Instance default_equality A : Equality A | 1000 :=
{ eqp := eq }.
Check (eqp 0%nat 0).
(* Defaulting *) Check (fun x y => eqp x y). (* No more defaulting, reduce "trigger-happiness" *) Definition ambiguous x y := eqp x y.
#[export] Hint Mode Equality ! : typeclass_instances.
Fail Definition ambiguous' x y := eqp x y. Definition nonambiguous (x y : nat) := eqp x y.
(** Typical looping instances with defaulting: *) Definition flip {A B C} (f : A -> B -> C) := fun x y => f y x.
Class SomeProp {A : Type} (f : A -> A -> A) :=
{ prf : forall x y, f x y = f x y }.
#[export] Instance propflip (A : Type) (f : A -> A -> A) :
SomeProp f -> SomeProp (flip f). Proof. intros []. constructor. reflexivity. Qed.
Fail Timeout 1 Check prf.
#[export] Hint Mode SomeProp + + : typeclass_instances. Check prf. Check (fun H : SomeProp plus => _ : SomeProp (flip plus)).
(** Iterative deepening / breadth-first search *)
Module IterativeDeepening.
Class A. Class B. Class C.
#[export] Instance: B -> A | 0 := {}.
#[export] Instance: C -> A | 0 := {}.
#[export] Instance: C -> B -> A | 0 := {}.
#[export] Instance: A -> A | 0 := {}.
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.