From: Andreas Rossberg <rossberg@mpi-sws.org>
To: rixed@happyleptic.org
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Strange behavior from type inference after functor application
Date: Fri, 1 Jun 2012 00:36:59 +0200 [thread overview]
Message-ID: <3C31823E-C0B6-49B5-928D-BD6083559841@mpi-sws.org> (raw)
In-Reply-To: <20120531212229.GB28948@yeeloong.happyleptic.org>
On May 31, 2012, at 23.22 h, rixed@happyleptic.org wrote:
> -[ Thu, May 31, 2012 at 10:23:13PM +0200, Gabriel Scherer ]----
>> The problem with
>> module C = Combi (S) (TypeWithConf (struct let v = 1 end))
>> is that the resulting type has no "name": (struct let v = 1 end) can
>> not be part of a type path.
>
> So in order for the compiler to infer a type the type must have a
> 'name'?
> That's funny because this 'name' is not used anywhere. Couldn't just
> such anonymous modules be given random names so that everything
> works as
> long as these names are unused? I mean, in the given example no type
> of
> this Conf module was required to infer that C.t is a product type
> (which
> was everything needed since f was returning the first value).
>
> Or would it be just too obscure and not useful enough?
The compiler has to give a module type to the module C, and the OCaml
type system insists that any module type it computes is expressible by
a syntactically valid signature. So it has to find one that avoids
mentioning S2.t. The only way to do so in a syntactically valid manner
is to make t abstract altogether in the resulting signature.
This is known as the "avoidance problem" in literature on ML modules.
The only solution to avoid the avoidance problem is to not insist on
syntactic signatures during type checking, which is essentially what
you suggest (although it's a bit more complicated in general). Other
dialects of ML modules indeed work like that, but it would be quite a
fundamental change to the way module type checking is done in OCaml.
/Andreas
prev parent reply other threads:[~2012-05-31 22:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-31 20:05 rixed
2012-05-31 20:23 ` Gabriel Scherer
2012-05-31 21:22 ` rixed
2012-05-31 22:36 ` Andreas Rossberg [this message]
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=3C31823E-C0B6-49B5-928D-BD6083559841@mpi-sws.org \
--to=rossberg@mpi-sws.org \
--cc=caml-list@inria.fr \
--cc=rixed@happyleptic.org \
/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