🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fa.caml
Article #145

Re: [Caml-list] using infix operators/functions in modules when not using "open"

#145
From: Gabriel Scherer
Date: Fri, 27 Apr 2012 06:58
53 lines
4935 bytes
> 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.

On Fri, Apr 27, 2012 at 1:01 AM, Haoyang Wang <hywang@pobox.com> wrote:
>
> On Apr 26, 2012, at 3:36 PM, ocamllist.robertwork@spamgourmet.com wrote:
>
>> I'm a OCaml newbie. �I don't understand how to use infix functions that are in modules when I don't want to use "open".
>>
>> I did discover http://xahlee.org/ocaml/functions.html which explains that an infix operator can be used as a prefix. �So, this format:
>>
>> � ((Module.(op)) "foo" "bar")
>>
>> does seem to work. �But, intuitively, it seems like:
>>
>> �"foo" Module.(op) "bar"
>>
>> would work -- it doesn't.
>>
>> Is there a way to keep the infix notation?
>>
>> Thanks.
>
>
> Module.("foo" (op) "bar")
>
> --
> Caml-list mailing list. �Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>


-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
Technical Details
Message-ID: <fa.VRDGQaDfMonLLnEft+4Fcf3ucEU@ifi.uio.no>
Path: arc1-ca.pugleaf.net!r9ni103495pbh.0!nntp.google.com!news1.google.com!goblin2!goblin1!goblin.stu.neva.ru!uio.no!nntp.uio.no!.POSTED!not-for-mail
References: <fa.ofhQjxcsFv94sv/nWA+yTdO/Akc@ifi.uio.no> <fa.M6cVL/vUGSfNoz3BI3kTRG8al/c@ifi.uio.no>

Show Full Headers
Complete Article Headers
X-Google-Thread: ff861,b3875ae36b84daab
X-Google-NewGroupId: yes
X-Google-Attributes: gidc0fe4b917e,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII
Received: by 10.68.125.233 with SMTP id mt9mr8340459pbb.5.1335509897767;
        Thu, 26 Apr 2012 23:58:17 -0700 (PDT)
Path: arc1-ca.pugleaf.net!r9ni103495pbh.0!nntp.google.com!news1.google.com!goblin2!goblin1!goblin.stu.neva.ru!uio.no!nntp.uio.no!.POSTED!not-for-mail
From: Gabriel Scherer <gabriel.scherer@gmail.com>
Newsgroups: fa.caml
Subject: Re: [Caml-list] using infix operators/functions in modules when not
 using "open"
Date: Fri, 27 Apr 2012 06:58:17 UTC
Organization: Internet mailing list
Lines: 54
Message-ID: <fa.VRDGQaDfMonLLnEft+4Fcf3ucEU@ifi.uio.no>
References: <fa.ofhQjxcsFv94sv/nWA+yTdO/Akc@ifi.uio.no> <fa.M6cVL/vUGSfNoz3BI3kTRG8al/c@ifi.uio.no>
NNTP-Posting-Host: mail-jess.uio.no
Mime-Version: 1.0
X-Trace: readme.uio.no 1335509897 29278 129.240.7.9 (27 Apr 2012 06:58:17 GMT)
X-Complaints-To: abuse@uio.no
NNTP-Posting-Date: Fri, 27 Apr 2012 06:58:17 +0000 (UTC)
Cc: caml-list@inria.fr
To: Haoyang Wang <hywang@pobox.com>
X-IronPort-AV: E=Sophos;i="4.75,489,1330902000"; 
   d="scan'208";a="155855853"
X-Authentication-Warning: walapai.inria.fr: sympa set sender to caml-list-owner@inria.fr using -f
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: Av0BALFCmk/RVdK2kWdsb2JhbABFn22SAggiAQEBAQkJDQcSKYIJAQEBAwESAiwBGxILAQMBCwYFCwMKDSEiAREBBQEKEgYTEgkHh1wBAwYFC51ACowjgnOFGQoZJwMKV4h2AQULkTgElX2BEY1PPYQN
X-IronPort-AV: E=Sophos;i="4.75,489,1330902000"; 
   d="scan'208";a="141802413"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :cc:content-type:content-transfer-encoding;
        bh=ZP3PH/xz2nZJi05O5ZR5DVqN4Voh5/HulDjtNWmvuSE=;
        b=z9sMEhv3FVYYjUVQ8fsQjs5NIpAFGOqQDTiJRP5UyBjuZG6DpbL/2XQYl2/CN+vrGC
         TwwaAJNeInPO4AZ9DPoYXWzrlRcjlWMN5Kbzh6vKDD8TYuHBPCCKLu1R9fPrPTuv6dUV
         1EOAX6A5/7z9Nngb5sQOgaTwjfYYcG8KWNcZuCkuKAUtsNHHDXfEV8QYUym/w/OVCvW3
         btdnIZaN5X+gpTMQKuBk3zsuqzeZShrRhiju5JZwtl5naerGiHtEm6ttt+caKpP8Scze
         cnyp2MF9s6I9Qqbd/IFO2wE+j7HyRyHMqByqugyiTw+GsL8kn0ba2CP8tyBmQN9fQdKg
         1YaQ==
In-Reply-To: <3C0F509D-8590-4D45-A586-83630088C7B5@pobox.com>
X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id q3R6vtUX029471
X-Sequence: 3975
List-Id: <caml-list.inria.fr>
List-Archive: <https://sympa-roc.inria.fr/wws/arc/caml-list>
List-Help: <mailto:sympa@inria.fr?subject=help>
List-Owner: <mailto:caml-list-request@inria.fr>
List-Post: <mailto:caml-list@inria.fr>
List-Subscribe: <mailto:sympa@inria.fr?subject=subscribe%20caml-list>
List-Unsubscribe: <mailto:sympa@inria.fr?subject=unsubscribe%20caml-list>
Original-Date: Fri, 27 Apr 2012 08:57:08 +0200
Original-Message-Id: <CAPFanBEofozEj3dRVU_c9_J2LUSp1DH7X8R=02GBd8BriFoLFA@mail.gmail.com>
Original-References: <CAN2fQM6PmfgkBspx1Js0yq8r2hbtd15mhvDXQ6tUcmAL46q=rw@mail.gmail.com>
 <3C0F509D-8590-4D45-A586-83630088C7B5@pobox.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit