caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Yotam Barnoy <yotambarnoy@gmail.com>
To: Jeremy Yallop <yallop@gmail.com>
Cc: "Hezekiah M. Carty" <hez@0ok.org>,
	Hendrik Boom <hendrik@topoi.pooq.com>,
	 Ocaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Warnings opening modules (was: why is building ocaml hard?)
Date: Fri, 15 Jul 2016 16:25:10 -0400	[thread overview]
Message-ID: <-5973449789047308640@unknownmsgid> (raw)
In-Reply-To: <CAAxsn=FkbirD2mat0vGUaems77RNeApupJDMAuHod=Gx=Exu2w@mail.gmail.com>

That's right -- I haven't touched our Haskell code in a while and
forgot about this detail.

It's nice to know that this is possible in ocaml, but it's clearly
inadequate for manually importing constructors. Perhaps this aspect
(importing constructors) should be improved, since the others can be
emulated. Or maybe open should be enhanced.

While thinking about open, it would also be nice to think of similarly
adequate solutions for modules that aren't opened but are still
limited to a specific interface (qualified importing in Haskell).

 A solution that covers both cases with minimal changes would
obviously be ideal.

> On Jul 15, 2016, at 3:52 PM, Jeremy Yallop <yallop@gmail.com> wrote:
>
>> On 15/07/2016, Yotam Barnoy <yotambarnoy@gmail.com> wrote:
>>> On Jul 15, 2016, at 3:26 PM, Hezekiah M. Carty <hez@0ok.org> wrote:
>>> On Fri, Jul 15, 2016 at 2:58 PM Yotam Barnoy <yotambarnoy@gmail.com> wrote:
>>>>>> On Jul 15, 2016, at 2:09 PM, Jeremy Yallop <yallop@gmail.com> wrote:
>>>>>> On 15 July 2016 at 17:57, Yotam Barnoy <yotambarnoy@gmail.com> wrote:
>>>>>> In haskell, I can just say 'import A (foo, bar, baz, t)' to limit
>>>>>> exactly what I want to import. This is because haskell has a
>>>>>> half-baked module system that isn't nearly as powerful as OCaml's,
>>>>>> which allows it to create syntax that doesn't need to go anywhere but
>>>>>> at the toplevel.
>>>>>>
>>>>>> We need this functionality in OCaml, but the closest thing is to say
>>>>>> 'include struct let foo = A.foo let bar = A.bar let baz = A.baz type t
>>>>>> = A.t end'
>>>>>
>>>>> This can be written more succinctly:
>>>>>
>>>>>  let foo, bar, baz = A.(foo, bar, baz)
>>>>>  type t = A.t
>>>>
>>>> Ok I have to admit that's pretty convenient.
>>> type t = M.t does not bring M.t's constructors into scope.  ppx_import (
>>> https://github.com/whitequark/ppx_import) can help with this if you don't
>>> mind preprocessing.
>>
>> That's a great point. Without that last bit of functionality, this isn't
>> really a solution to the problem.
>
> The Haskell example you gave:
>
>   import A(T)
>
> doesn't bring T's constructors into scope, either; it needs to be
> written like this:
>
>   import A(T(..))
>
> In OCaml you can bring A.t's constructors into scope by repeating the
> definition:
>
>   type t = A.t = T of int

  reply	other threads:[~2016-07-15 20:25 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-10 11:57 David Allsopp
2016-07-10 19:45 ` Gerd Stolpmann
2016-07-13 12:08   ` David Allsopp
2016-07-13 12:20     ` Gerd Stolpmann
2016-07-13 12:30       ` David Allsopp
2016-07-14  9:03     ` Goswin von Brederlow
2016-07-15  9:52       ` David Allsopp
2016-07-15 16:13         ` Hendrik Boom
2016-07-15 16:57           ` Yotam Barnoy
2016-07-15 18:09             ` Jeremy Yallop
2016-07-15 18:26               ` Hendrik Boom
2016-07-15 18:58               ` Yotam Barnoy
2016-07-15 19:26                 ` Hezekiah M. Carty
2016-07-15 19:42                   ` Yotam Barnoy
2016-07-15 19:52                     ` Jeremy Yallop
2016-07-15 20:25                       ` Yotam Barnoy [this message]
2016-07-15 18:50             ` Alain Frisch
2016-07-15 19:44               ` Hendrik Boom
2016-07-15 17:04           ` Gerd Stolpmann
2016-07-20  7:49             ` Louis Gesbert
2016-07-16  7:40           ` Petter A. Urkedal
2016-07-16  9:58             ` vrotaru.md
2016-07-19 16:37               ` Yotam Barnoy

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=-5973449789047308640@unknownmsgid \
    --to=yotambarnoy@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=hendrik@topoi.pooq.com \
    --cc=hez@0ok.org \
    --cc=yallop@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).