From: Julien Signoles <Julien.Signoles@cea.fr>
To: Pietro Abate <Pietro.Abate@pps.jussieu.fr>,
caml list <caml-list@inria.fr>
Subject: Re: [Caml-list] small typing problem with modules ...
Date: Tue, 26 May 2009 14:37:18 +0200 [thread overview]
Message-ID: <4A1BE27E.8030908@cea.fr> (raw)
In-Reply-To: <20090526093727.GA28741@uranium.pps.jussieu.fr>
Hello,
> My problem here is that I'd like to have a module type T for the functor
> Make in b.ml and to avoid the signature duplication in b.mli ... ideally
> I'd like to write in b.mli something like :
>
> module type T = sig ???? end
> module Make : functor (Extra : A.Extra) ->
> functor (A : A.T with type extra = Extra.t) -> T with ...
> include T with ...
>
> It's clear that I cannot write a module type as follows because the
> the "open A" will consider the default type of A and not it's
> parametrized version ...
>
> module type T = sig
> open A
> val f : extra -> unit
> end
>
> how can I parametrize this signature ? I can write something like :
> module type T = functor (A : A.T) ->
> sig
> open A
> val f : extra -> unit
> end ;;
>
> but then I'm a bit lost putting all this together ...
> I know I'm close ... a small hint ?
Hum, module types cannot be parameterized. If you want to use a functor
signature, you can write the following :
=====
module type T =
functor (Extra : A.Extra) ->
functor (A : A.T with type extra = Extra.t) ->
sig val f : A.extra -> unit end
module Make : T
open A
val f : extra -> unit
=====
But I'm pretty sure that is not really what is expected...
However why cannot you just add an another abstract type in your
signature like below?
=====
module type T = sig
type extra
val f : extra -> unit
end
module Make(Extra : A.Extra)(A : A.T with type extra = Extra.t)
: T with type extra = A.extra
open A
val f : extra -> unit
=====
Hope this helps,
Julien Signoles
next prev parent reply other threads:[~2009-05-26 12:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-26 9:37 Pietro Abate
2009-05-26 12:37 ` Julien Signoles [this message]
2009-05-26 13:12 ` [Caml-list] " Pietro Abate
2009-05-26 13:35 ` Andreas Rossberg
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=4A1BE27E.8030908@cea.fr \
--to=julien.signoles@cea.fr \
--cc=Pietro.Abate@pps.jussieu.fr \
--cc=caml-list@inria.fr \
/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