From: Shayne Fletcher <shayne.fletcher.50@gmail.com>
To: Nicolas Ojeda Bar <nicolas.ojeda.bar@lexifi.com>
Cc: "caml-list@inria.fr users" <caml-list@inria.fr>
Subject: Re: [Caml-list] Functor signature "inheritance"
Date: Fri, 28 Oct 2016 12:12:21 -0400 [thread overview]
Message-ID: <CAMsAzy-hCZAE-9FVjbzTwFYpepM6ouk8poQNNh9_=yrpehLYEQ@mail.gmail.com> (raw)
In-Reply-To: <CAMsAzy9tG0eiimcfM4X3CR-N_ymeKkGTfx3Ao_7Bu=vOo4SSWA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1392 bytes --]
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 = functor (E : EQ) (N : NUM with type t = E.t) ->
>> MUL_S with module N := N and module E := E
>>
>
> That does it! I tried so many different things :) You're a rock 'n roll
> star.
>
Still stuck on how to achieve this I'm afraid.
module type EQ = sig
type t
val eq : t * t -> bool
end
module type NUM = sig
type t
val from_int : int -> t
val ( + ) : t -> t -> t
end
module type MUL_S = sig
include EQ
include NUM with type t := t
val mul : t -> t -> t
end
module type MUL = functor (E : EQ) (N : NUM with type t = E.t) -> MUL_S
module Mul_default (E : EQ) (N : NUM with type t = E.t) : MUL = struct
include E
include (N : NUM with type t := E.t)
let mul (x : t) (y : t) : t = failwith "foo"
end
Yields.
Error: Signature mismatch:
Modules do not match:
sig
type t = 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
--
Shayne Fletcher
[-- Attachment #2: Type: text/html, Size: 5259 bytes --]
next prev parent reply other threads:[~2016-10-28 16:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-28 12:44 Shayne Fletcher
2016-10-28 13:01 ` Nicolas Ojeda Bar
2016-10-28 13:04 ` Shayne Fletcher
2016-10-28 13:14 ` Shayne Fletcher
2016-10-28 13:25 ` Nicolas Ojeda Bar
2016-10-28 13:28 ` Shayne Fletcher
2016-10-28 13:47 ` rixed
2016-10-28 13:55 ` Shayne Fletcher
2016-10-28 15:44 ` Gabriel Scherer
2016-10-29 1:59 ` Shayne Fletcher
2016-10-28 16:12 ` Shayne Fletcher [this message]
2016-10-28 16:16 ` Shayne Fletcher
2016-10-28 16:17 ` Shayne Fletcher
2016-10-28 16:17 ` Nicolas Ojeda Bar
2016-10-28 16:36 ` Shayne Fletcher
2016-10-29 18:43 ` Shayne Fletcher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMsAzy-hCZAE-9FVjbzTwFYpepM6ouk8poQNNh9_=yrpehLYEQ@mail.gmail.com' \
--to=shayne.fletcher.50@gmail.com \
--cc=caml-list@inria.fr \
--cc=nicolas.ojeda.bar@lexifi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox