From: rossberg@mpi-sws.org
To: "Dawid Toton" <d0@wp.pl>
Cc: "caml-list" <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Re: Module type of a structure returned by functor
Date: Mon, 26 Apr 2010 18:54:47 +0200 (CEST) [thread overview]
Message-ID: <5ac779c6dcc89fe009150414e374043c.squirrel@mail.mpi-sws.org> (raw)
In-Reply-To: <4BD5C057.7020800@wp.pl>
Dawid Toton <d0@wp.pl> wrote:
> I've found that I have more fundamental problem. What is the exact
> meaning of the following line?
>
> module type Foo = functor (X:X) -> sig val foo : X.t end
>
> (1) Foo is not a functor, but it is a type of some functors that map
> modules to modules
> (2) Foo is a mapping from modules to module types
>
> Currently I think that it (1) is true and (2) is false. Let me know if
> I'm wrong.
That's right. A construct for (2), sometimes referred to as "parameterized
signatures", does not exist in OCaml directly. However, you can encode it
using a functor with a nested signature in its result:
module FooOf (X : X) =
struct
module type S = sig val foo : X.t end
end
Now, for example:
module F (X : X) (Y : FooOf(X).S) = ...
> It means that there is no easy way to get module type of what results
> from functor application. I think that the solution is to separately
> define signature of results of the functor and use "with type" clauses
> to recreate all result module types that are needed.
>
> This is not very bad, but I'm still wondering if "module type of..." of
> 3.12 will provide elegant solution for this.
Interesting, it looks like it may. I wasn't aware that singleton
signatures will be coming in 3.12 - nice.
/Andreas
next prev parent reply other threads:[~2010-04-26 16:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-23 23:14 Dawid Toton
2010-04-26 16:33 ` Dawid Toton
2010-04-26 16:48 ` [Caml-list] " Vincent Aravantinos
2010-04-26 16:54 ` rossberg [this message]
2010-04-27 0:23 ` [Caml-list] " Jacques Garrigue
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=5ac779c6dcc89fe009150414e374043c.squirrel@mail.mpi-sws.org \
--to=rossberg@mpi-sws.org \
--cc=caml-list@yquem.inria.fr \
--cc=d0@wp.pl \
/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