coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Matthieu Sozeau <mattam AT mattam.org>
- To: Pierre Casteran <pierre.casteran AT labri.fr>
- Cc: coq-club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] Class Instances on the same type
- Date: Mon, 11 Apr 2011 18:02:32 +0200
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; b=un50M7YYAepYDqyuZI4YOUFi+78h7xIntFF9hG3KDWQlNF0b6eq+D1fNcwjLaGjv0b dL/nyYbx4uyPusVuJQj8IkJunoDKoTiq3HeffJAvN5PWnAMMojsvc/yn9qwoviY5qzPt hoYG2MJ6hyH4+m2UGvt4+Ua0ukFBkmVUYOqrk=
Le 11 avr. 2011 à 17:51, Pierre Casteran a écrit :
> Hello,
>
> I define a class
>
> Class Monoid (A:Type) : Type := {
> dot : A -> A -> A;
> id : A;
> dot_assoc : forall x y z:A, dot x (dot y z)= dot (dot x y) z;
> id_left : forall x, dot id x = x;
> id_right : forall x, dot x id = x}.
>
> and build two instances on Z of class (Monoid Z) : Z_add (additive
> monoid) and
> Z_mult (multiplicative monoid).
>
> Is there a simple way to specify (locally or globally) which of both
> instances can
> be considered as the default one, when analyzing an undecorated term like
> for instance
> fun z:Z => dot z (dot z z) ?
Hi,
You can specify different costs for the instances, and the matching instances
of the lowest
cost are applied first. This can only be set globally, at definition time (at
least for now).
The syntax is [Instance foo: Bar A | 10] where 10 is the cost.
-- Matthieu
- [Coq-Club] Class Instances on the same type, Pierre Casteran
- Re: [Coq-Club] Class Instances on the same type, Matthieu Sozeau
- Re: [Coq-Club] Class Instances on the same type,
Daniel Schepler
- Re: [Coq-Club] Class Instances on the same type, Pierre Casteran
- Re: [Coq-Club] Class Instances on the same type,
Daniel Schepler
- Re: [Coq-Club] Class Instances on the same type, Matthieu Sozeau
Archive powered by MhonArc 2.6.16.