caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Leo White <lpw25@cam.ac.uk>
To: Berke Durak <berke.durak@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Ocaml 4.02.0+dev4-2014-04-03 toplevel: module aliases no longer print module signature
Date: Sun, 27 Apr 2014 15:34:48 +0100	[thread overview]
Message-ID: <87r44i96yf.fsf@study.localdomain> (raw)
In-Reply-To: <20140427134510.GB28200@gmail.com> (Berke Durak's message of "Sun, 27 Apr 2014 09:45:11 -0400")

The semantics of module aliases has changed in 4.02, so now:

    module S = String

creates a proper alias to String. This means, for example, that the type
`Map.Make(String).t` is now equivalent to `Map.Make(S).t`:

            OCaml version 4.02.0+dev4-2014-04-03

    # module S = String;;
    module S = String
    # let f (x : 'a Map.Make(String).t) : 'a Map.Make(S).t = x;;
    val f : 'a Map.Make(String).t -> 'a Map.Make(S).t = <fun>

where as previously:

            OCaml version 4.01.0
    # module S = String;;
    module S :
      sig
        [...]
      end
    # let f (x : 'a Map.Make(String).t) : 'a Map.Make(S).t = x;;
    Characters 55-56:
      let f (x : 'a Map.Make(String).t) : 'a Map.Make(S).t = x;;
                                                             ^
    Error: This expression has type 'a Map.Make(String).t
           but an expression was expected of type 'a Map.Make(S).t

In order to expose such aliases in signatures, you can now write `module
S = String` in signatures as well as structures. This is why the output
from the top-level has changed: it is still printing the type of `S`,
but `S` now has type `= String`.

To help people who previously defined aliases to print a module's
contents, the `#show` directive has been added to the top-level:

    # #show module String;;
    module String :
      sig
        [...]
      end

Regards,

Leo

Berke Durak <berke.durak@gmail.com> writes:

> On Sun, Apr 27, 2014 at 09:18:26AM -0400, Yaron Minsky wrote:
>> Sends preferable behavior to me, since it avoid overly long signatures and
>> more clearly reflects the new semantics of module aliases.
>
> If that's the issue, when the toplevel is connected to a tty, it should cut the
> output at some point and put an ellipsis.  If it's not a tty, it should still
> blast the full signature.
>
> I'm surely not the only one who has been relying on module X = Blah to see the
> signature of a module.  Old habits die hard.
>
> Also module SM = Map.Make(String) still prints the full declaration.
>
>> But it might be nice to have a way to see the contents of a module in the
>> toplevel.  Maybe steak the #typeof declaration from utop?
>
> How does one print a module signature in utop?
>
> -- 
> Berke Durak

  parent reply	other threads:[~2014-04-27 14:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-27 12:52 Berke Durak
2014-04-27 13:18 ` Yaron Minsky
2014-04-27 13:45   ` Berke Durak
2014-04-27 13:58     ` ygrek
2014-04-27 14:19       ` Berke Durak
2014-04-27 14:21         ` Daniel Bünzli
2014-04-27 14:59           ` Berke Durak
2014-04-27 14:34     ` Leo White [this message]
2014-04-27 15:02       ` Berke Durak
2014-04-27 14:04   ` Malcolm Matalka
2014-05-03 20:18 ` Richard W.M. Jones
2014-05-03 20:21   ` Anil Madhavapeddy
2014-05-03 22:00     ` Richard W.M. Jones

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=87r44i96yf.fsf@study.localdomain \
    --to=lpw25@cam.ac.uk \
    --cc=berke.durak@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).