From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 9B44E7EE89 for ; Fri, 28 Oct 2016 18:17:47 +0200 (CEST) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=nicolas.ojeda.bar@lexifi.com; spf=None smtp.mailfrom=nicolas.ojeda.bar@lexifi.com; spf=None smtp.helo=postmaster@vrout10.yaziba.net Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of nicolas.ojeda.bar@lexifi.com) identity=pra; client-ip=185.56.204.32; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nicolas.ojeda.bar@lexifi.com"; x-sender="nicolas.ojeda.bar@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of nicolas.ojeda.bar@lexifi.com) identity=mailfrom; client-ip=185.56.204.32; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nicolas.ojeda.bar@lexifi.com"; x-sender="nicolas.ojeda.bar@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@vrout10.yaziba.net) identity=helo; client-ip=185.56.204.32; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nicolas.ojeda.bar@lexifi.com"; x-sender="postmaster@vrout10.yaziba.net"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AS968Bx8qXJmulv9uRHKM819IXTAuvvDOBiVQ1KB9?= =?us-ascii?q?2u4cTK2v8tzYMVDF4r011RmSDN+dtKkP2rSempujcFRI2YyGvnEGfc4EfD4+ou?= =?us-ascii?q?JSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47AblHf6ke/8SQVUk2mc1Ek?= =?us-ascii?q?fKKqQcWD0Yye7KObw9XreQJGhT6wM/tZDS6dikHvjPQQmpZoMa0ryxHE8TNicu?= =?us-ascii?q?VSwn50dxrIx06vru/5xpNo8jxRtvQ97IYAFPyiJ+VrBYBfWQ8mOnEz6YXFsRTf?= =?us-ascii?q?RguC/DNISWUfgxxFRQbB4Q3xXprr9HainuV40Siee8bxSOZndy6l6vJNSRTvjC?= =?us-ascii?q?4cfxk7/W3ewuZ5luoPphOqoBh22MjTYoyZPbx0d7n1ed4KRGRAGM1WUnoSUcuH?= =?us-ascii?q?c4ITAr9Zbq5jpI7nqg5L9EPmCA=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0BNAgDWeRNYgCDMOLldHAEBBAEBCgEBF?= =?us-ascii?q?wEBBAEBCgEBgn8BAQEBAYF0B6Qth16HRocihiMCgXcHQhEBAQEBAQEBAQEBARI?= =?us-ascii?q?BAQsLCQkbMoIzBAEVAQSCEQEBBBIRBFIQCQILDSoCAiEBEgEFARwGEyKIGAMXB?= =?us-ascii?q?AGTUI9NgTI/MotGiHINg2QBAQEHAQEBAQEiixKCR4UEglsBBJQ6hSk1h2WFGoM?= =?us-ascii?q?okASIc4Qcgj8THoEPAjRxgykcgVVwAYYogUoBAQE?= X-IPAS-Result: =?us-ascii?q?A0BNAgDWeRNYgCDMOLldHAEBBAEBCgEBFwEBBAEBCgEBgn8?= =?us-ascii?q?BAQEBAYF0B6Qth16HRocihiMCgXcHQhEBAQEBAQEBAQEBARIBAQsLCQkbMoIzB?= =?us-ascii?q?AEVAQSCEQEBBBIRBFIQCQILDSoCAiEBEgEFARwGEyKIGAMXBAGTUI9NgTI/Mot?= =?us-ascii?q?GiHINg2QBAQEHAQEBAQEiixKCR4UEglsBBJQ6hSk1h2WFGoMokASIc4Qcgj8TH?= =?us-ascii?q?oEPAjRxgykcgVVwAYYogUoBAQE?= X-IronPort-AV: E=Sophos;i="5.31,410,1473112800"; d="scan'208,217";a="198536226" Received: from vrout10.yaziba.net ([185.56.204.32]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 28 Oct 2016 18:17:25 +0200 Received: from mtaout20.int.yaziba.net (mtaout20.int.yaziba.net [10.4.20.37]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by vrout10.yaziba.net (mx10.yaziba.net) with ESMTPS id F2FC051FA6 for ; Fri, 28 Oct 2016 18:17:24 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mtaout20.int.yaziba.net (Postfix) with ESMTP id 0C22F1603B5 for ; Fri, 28 Oct 2016 18:17:25 +0200 (CEST) X-Virus-Scanned: amavisd-new at mtaout20.int.yaziba.net Received: from mtaout20.int.yaziba.net ([127.0.0.1]) by localhost (mtaout20.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id fMjCwopFP3FE for ; Fri, 28 Oct 2016 18:17:24 +0200 (CEST) Received: from mail-qk0-f171.google.com (mail-qk0-f171.google.com [209.85.220.171]) by mtaout20.int.yaziba.net (Postfix) with ESMTPSA id CED881602FC for ; Fri, 28 Oct 2016 18:17:24 +0200 (CEST) Received: by mail-qk0-f171.google.com with SMTP id v138so1792163qka.0 for ; Fri, 28 Oct 2016 09:17:24 -0700 (PDT) X-Gm-Message-State: ABUngvdZR351XgiU6xWLt4qC9E2o6qNdDnOpqYaZNIgjo+bTDk5p5+dHihZL4dcJ+kpLHgJmAYKgPaYDFg88iA== X-Received: by 10.55.64.80 with SMTP id n77mr12721620qka.173.1477671443758; Fri, 28 Oct 2016 09:17:23 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.53.109 with HTTP; Fri, 28 Oct 2016 09:17:03 -0700 (PDT) In-Reply-To: References: From: Nicolas Ojeda Bar Date: Fri, 28 Oct 2016 18:17:03 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Shayne Fletcher Cc: "caml-list@inria.fr users" Content-Type: multipart/alternative; boundary=001a1148b73e800bf5053fef31f7 X-DRWEB-SCAN: ok X-VRSPAM-SCORE: -100 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrfeelvddrjeefgddutddtucetufdoteggodetrfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpegjfhfhfffkuffvtgesrgdtreertddtjeenucfhrhhomheppfhitgholhgrshcuqfhjvggurgcuuegrrhcuoehnihgtohhlrghsrdhojhgvuggrrdgsrghrsehlvgigihhfihdrtghomheqnecukfhppedvtdelrdekhedrvddvtddrudejudenucfrrghrrghmpehmohguvgepshhmthhpohhuth X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht Subject: Re: [Caml-list] Functor signature "inheritance" --001a1148b73e800bf5053fef31f7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Shayne, I did not try it, but I think you want module Mul_default : MUL =3D functor (E : EQ) (N : NUM with type t =3D E.t)= -> struct include E include (N : NUM with type t :=3D E.t) let mul (x : t) (y : t) : t =3D failwith "foo" end Cheers, Nicolas On Fri, Oct 28, 2016 at 6:12 PM, Shayne Fletcher < shayne.fletcher.50@gmail.com> wrote: > > On Fri, Oct 28, 2016 at 9:28 AM, Shayne Fletcher < > shayne.fletcher.50@gmail.com> wrote: > >> On Fri, Oct 28, 2016 at 9:25 AM, Nicolas Ojeda Bar < >> nicolas.ojeda.bar@lexifi.com> wrote: >> >>> You can add a constrain to your functor arguments : >>> >>> module type MUL =3D functor (E : EQ) (N : NUM with type t =3D E.t) -> >>> MUL_S with module N :=3D N and module E :=3D E >>> >> >> =E2=80=8BThat does it! I tried so many different things :) You're a rock= 'n roll >> star. >> > > =E2=80=8BStill stuck on how to achieve this I'm afraid. > > module type EQ =3D sig > type t > val eq : t * t -> bool > end > > module type NUM =3D sig > type t > val from_int : int -> t > val ( + ) : t -> t -> t > end > > module type MUL_S =3D sig > include EQ > include NUM with type t :=3D t > > val mul : t -> t -> t > end > > module type MUL =3D functor (E : EQ) (N : NUM with type t =3D E.t) -> MUL= _S > > module Mul_default (E : EQ) (N : NUM with type t =3D E.t) : MUL =3D stru= ct > > include E > include (N : NUM with type t :=3D E.t) > > let mul (x : t) (y : t) : t =3D failwith "foo" > > end > > Yields. > > =E2=80=8BError: Signature mismatch: > Modules do not match: > sig > type t =3D E.t > val eq : t * t -> bool > val from_int : int -> E.t > val ( + ) : E.t -> E.t -> E.t > val mul : t -> t -> t > end > is not included in > MUL=E2=80=8B > > -- > Shayne Fletcher > --001a1148b73e800bf5053fef31f7 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Shayne,

I did not try it, but I thin= k you want

module Mul_default : MUL =3D funct= or (E : EQ) (N : NUM with type t =3D E.t) =C2=A0-> struct
=C2= =A0 =C2=A0 include E
=C2=A0 =C2=A0 include (N : NUM with type= t :=3D E.t)

=C2=A0 =C2=A0 let mul (x : t) (y : t)= : t =3D failwith "foo"
end

<= div>Cheers,
Nicolas


On Fri, Oct 28, 2016 at 6:12 PM, Sha= yne Fletcher <shayne.fletcher.50@gmail.com> wrote= :

On Fri, Oct 28, 2016 a= t 9:28 AM, Shayne Fletcher <shayne.fletcher.50@gmail.com>= ; wrote:
On Fri, Oc= t 28, 2016 at 9:25 AM, Nicolas Ojeda Bar <nicolas.ojeda.bar@lex= ifi.com> wrote:
You can add a constrain to your functor arguments :
=
module type MUL =3D functor (E : EQ) (N : NUM with type t = =3D E.t) ->
=C2=A0 =C2=A0 MUL_S with module N :=3D N and= module E :=3D E

=E2=80=8BTh= at does it! I tried so many different things :) You're a rock 'n ro= ll star.

=E2=80=8BStill stuck on how to achieve this= I'm afraid.

module type EQ =3D sig
=C2=A0 type t
= =C2=A0 val eq : t * t -> bool
<= font face=3D"tahoma, sans-serif">end

module type NUM =3D sig
=C2=A0 ty= pe t
=C2=A0 val from_int : int -> t
=C2=A0 val ( + ) : t -> t -> t=
end

module type MUL_S =3D sig
=C2=A0 include EQ
=C2=A0 include= NUM with type t :=3D t

=C2=A0 val mul : t -> t -&= gt; t
end

module type MUL =3D functor (E : EQ)= (N : NUM with type t =3D E.t) -> MUL_S

module Mul_default (= E : EQ) (N : NUM with type t =3D E.t) : MUL =C2=A0=3D struct

=C2=A0 in= clude E
=C2=A0 include (N : NUM with type t :=3D E.t)

=C2=A0 let mul (= x : t) (y : t) : t =3D failwith "foo"

end

Yields.

=E2=80=8BError: Signature mismatch:
=C2=A0 =C2=A0 =C2=A0 =C2=A0M= odules do not match:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sig
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0type t =3D E.t
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0val eq : t * t -> bool
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0val from_int : int -> E.t
=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0val ( + ) : E.t -> E.t -> E.t
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0val mul : t -> t -> t
<= div class=3D"gmail_default" style=3D"font-family:tahoma,sans-serif">=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0end
=C2=A0 =C2=A0 =C2=A0 =C2=A0is not incl= uded in
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0MUL=E2=80=8B

--
Shayne Fletcher

--001a1148b73e800bf5053fef31f7--