caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Goswin von Brederlow <goswin-v-b@web.de>
To: Gabriel Scherer <gabriel.scherer@gmail.com>
Cc: Haoyang Wang <hywang@pobox.com>, caml-list@inria.fr
Subject: Re: [Caml-list] using infix operators/functions in modules when not using "open"
Date: Fri, 27 Apr 2012 10:30:18 +0200	[thread overview]
Message-ID: <87lilha86d.fsf@frosties.localnet> (raw)
In-Reply-To: <CAPFanBEofozEj3dRVU_c9_J2LUSp1DH7X8R=02GBd8BriFoLFA@mail.gmail.com> (Gabriel Scherer's message of "Fri, 27 Apr 2012 08:57:08 +0200")

Gabriel Scherer <gabriel.scherer@gmail.com> writes:

>> Module.("foo" (op) "bar")
>
> This is a local open (a more explicit notation is "let open Module in
> foo op bar"). I think this is a fine solution: I don't like open, but
> local mitigates its flaws.
>
> Another solution is to rebind your operator locally:
>
>   let (op) = Module.blah in
>   "foo" op "bar"
>
> (of course Module.blah doesn't need to be an infix itself)
>
> If you are going to use an infix operator in a wide scope, I think
> that such a rebinding solution is nice because it's more explicit,
> which is good when it helps users understand the code.

And that also works more globally as in

let (op) = Module.blah

let foo x y = x (op) y

MfG
        Goswin

      reply	other threads:[~2012-04-27  8:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-26 22:36 ocamllist.robertwork
2012-04-26 23:01 ` Haoyang Wang
2012-04-27  0:28   ` Anthony Tavener
2012-04-27  6:57   ` Gabriel Scherer
2012-04-27  8:30     ` Goswin von Brederlow [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=87lilha86d.fsf@frosties.localnet \
    --to=goswin-v-b@web.de \
    --cc=caml-list@inria.fr \
    --cc=gabriel.scherer@gmail.com \
    --cc=hywang@pobox.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).