caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Leo White <leo@lpw25.net>
To: Malcolm Matalka <mmatalka@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Are implicit modules too implicit?
Date: Wed, 02 Mar 2016 09:24:16 -0500	[thread overview]
Message-ID: <1456928656.1475915.537363338.6E334EDB@webmail.messagingengine.com> (raw)
In-Reply-To: <8637s9gev3.fsf@gmail.com>

> In this case I'm interested in if I have a block of code like the
> [print] function described in the paper knowing what possible code could
> even be executed there and how to define its definition.  For example,
> how do I go from [show 5] to the module [Show_int]?

I would expect to be able to ask merlin to automatically jump to [Show_int]
from [show 5]. I would also expect merlin to be able to produce
[show {Show_int} 5] given [show 5].
 
> In the paper, the Show implementation for an int is called Show_int and
> for list Show_list, etc.  But this is just a pleasant convention in the
> paper. 

And could easily be a pleasant convention in a library. Or possibly [Int.Show]
and [List.Show]. It's really a just a question of using sensible library design.

> What if implicit modules required specifying what module type
> they are implementing?  That would make finding instances of Show
> easier.  How this would look is in the paper:
> 
> implicit module Foo : Show = struct ... end
> 

That wouldn't work as it would make Foo.t abstract. If/when OCaml supported
transparent ascription (perhaps with :>) then you could write:

  implicit module Foo :> Show = struct ... end

which would at least be correct, but I don't really see the benefit of forcing users
to do this since the .mli file (which is where you should be looking for definitions
anyway) will already contain:

  implicit module Foo : Show with type t = ...

Of course it might contain:

  implicit module Foo : ShowAndOtherStuff with type t = ...

or even:

  implicit module Foo : sig type t = .. ... end

instead, but this is really a question of programming style, and those are best left
up to users/organisations to decide on.

> Do you have any thoughts on how you think implicit modules would effect
> understanding a large application?

The whole design of implicits is very careful to make things as explicit and
predictable as possible. The strict position that the design takes around
ambiguity (it is always an error) means that if you can see a module with the
right type in scope then that is the module being used. I do not think reasoning
about them will be difficult, but it obviously relies on people being sensible in
how they design their libraries (just like everything else in programming).
 
Regards,

Leo

  parent reply	other threads:[~2016-03-02 14:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-02 12:16 Malcolm Matalka
2016-03-02 13:37 ` Leo White
2016-03-02 13:59   ` Malcolm Matalka
2016-03-02 14:17     ` Yaron Minsky
2016-03-02 14:24     ` Leo White [this message]
2016-03-02 15:57       ` Malcolm Matalka
2016-03-02 18:59         ` Gabriel Scherer
2016-03-02 14:30   ` Gerd Stolpmann
2016-03-02 15:09     ` 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=1456928656.1475915.537363338.6E334EDB@webmail.messagingengine.com \
    --to=leo@lpw25.net \
    --cc=caml-list@inria.fr \
    --cc=mmatalka@gmail.com \
    /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).