caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jordan W <jordojw@gmail.com>
To: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: [Caml-list] Record fields not reexported from functors.
Date: Sun, 10 May 2015 14:58:10 -0700	[thread overview]
Message-ID: <CAPOA5_7X-wAxr8BwaUgz1u4rR00cphzgEKeQyPLwcNDT317NbQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1451 bytes --]

I believe there is an issue with record fields and functors.
It appears that while types are correctly exported from functors, the
corresponding record field scopes are not. Here is an example.

   module type HasType = sig
      type t
    end

    module EchoModule (Input:HasType): (HasType with type t = Input.t) =
(struct
      type t = Input.t
    end)

    module ClonedModuleWithRecordType = EchoModule (struct
      type t = {innerRecordField: int}
    end)

    (* This doesn't type check, but I can't see why it shouldn't. Record
fields'
       scopes should be reexported just like the types themselves.

      let myRecord: ClonedModuleWithRecordType.t = {
        ClonedModuleWithRecordType.innerRecordField=10;
      }

      In this case, the original "scope" of the record fields is "lost"
      because the record type was declared in an anonymous module
expression.  I
      believe that it *should* be "lost" as it is, but then reexported as an
      identical type in the module returned from the functor (identically
because
      of the "with constraint").

    *)

    module ClonedModuleWithNonRecordType = EchoModule (struct
      type t = string list
    end)

    (* This typechecks perfectly fine! Evidence that types are reexported,
but not
       the "scope" of record labels *)
    let myRecord: ClonedModuleWithNonRecordType.t = ["asdf"; "fff"]


Is anyone aware of whether or not this issue is already being tracked?

[-- Attachment #2: Type: text/html, Size: 2058 bytes --]

             reply	other threads:[~2015-05-10 21:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-10 21:58 Jordan W [this message]
2015-05-10 23:19 ` Jacques Garrigue
2015-05-11 17:24 ` Leo White

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=CAPOA5_7X-wAxr8BwaUgz1u4rR00cphzgEKeQyPLwcNDT317NbQ@mail.gmail.com \
    --to=jordojw@gmail.com \
    --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;
as well as URLs for NNTP newsgroup(s).