Article View: fa.caml
Article #146Re: [Caml-list] using infix operators/functions in modules when not using "open"
From: Goswin von Brederlow
Date: Fri, 27 Apr 2012 08:30
Date: Fri, 27 Apr 2012 08:30
33 lines
3859 bytes
3859 bytes
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
--
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.5lxhxOGpcJTnlsWwW4DgstmsGTE@ifi.uio.no>Path:
arc1-ca.pugleaf.net!r9ni103736pbh.0!nntp.google.com!news1.google.com!goblin2!goblin1!goblin.stu.neva.ru!uio.no!nntp.uio.no!.POSTED!not-for-mailReferences:
<fa.ofhQjxcsFv94sv/nWA+yTdO/Akc@ifi.uio.no> <fa.M6cVL/vUGSfNoz3BI3kTRG8al/c@ifi.uio.no> <fa.VRDGQaDfMonLLnEft+4Fcf3ucEU@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-7-bit
Received: by 10.68.125.233 with SMTP id mt9mr8568802pbb.5.1335515448916;
Fri, 27 Apr 2012 01:30:48 -0700 (PDT)
Path: arc1-ca.pugleaf.net!r9ni103736pbh.0!nntp.google.com!news1.google.com!goblin2!goblin1!goblin.stu.neva.ru!uio.no!nntp.uio.no!.POSTED!not-for-mail
From: Goswin von Brederlow <goswin-v-b@web.de>
Newsgroups: fa.caml
Subject: Re: [Caml-list] using infix operators/functions in modules when not using "open"
Date: Fri, 27 Apr 2012 08:30:48 UTC
Organization: Internet mailing list
Lines: 34
Message-ID: <fa.5lxhxOGpcJTnlsWwW4DgstmsGTE@ifi.uio.no>
References: <fa.ofhQjxcsFv94sv/nWA+yTdO/Akc@ifi.uio.no> <fa.M6cVL/vUGSfNoz3BI3kTRG8al/c@ifi.uio.no> <fa.VRDGQaDfMonLLnEft+4Fcf3ucEU@ifi.uio.no>
NNTP-Posting-Host: mail-jess.uio.no
Mime-Version: 1.0
X-Trace: readme.uio.no 1335515448 3092 129.240.7.9 (27 Apr 2012 08:30:48 GMT)
X-Complaints-To: abuse@uio.no
NNTP-Posting-Date: Fri, 27 Apr 2012 08:30:48 +0000 (UTC)
User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE)
Cc: Haoyang Wang <hywang@pobox.com>, caml-list@inria.fr
To: Gabriel Scherer <gabriel.scherer@gmail.com>
X-IronPort-AV: E=Sophos;i="4.75,490,1330902000";
d="scan'208";a="155869978"
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: AtUCAGdYmk/ZSMDqlGdsb2JhbABFsXsiAQEBAQkLCQkUAySCCQEBBAE6PxALISUPAQQNGyETG4djAQMGCbIwHysNiVOKB4c8BJtehVyHbQ
X-IronPort-AV: E=Sophos;i="4.75,490,1330902000";
d="scan'208";a="155869893"
In-Reply-To: <CAPFanBEofozEj3dRVU_c9_J2LUSp1DH7X8R=02GBd8BriFoLFA@mail.gmail.com>
(Gabriel Scherer's message of "Fri, 27 Apr 2012 08:57:08 +0200")
X-Provags-ID: V02:K0:dolJV28pC9wzXrBP1c9Klh075xtxaQJTnef+LtSS4EQ
qnNEzqzLDGiqPsilHhC2PiMVUUuymVP0SZrDup4fUBFhBRUOCf
/KIebDxR+HCMLs39tW49lZYkE524abeZJHLvCsrDRJVqCtKIHH
o6wax+wRRG0g8JyVjDFfWMjPNFGyT3L2tjnyOIiRVBTEL+O1ff
6QRZ72xhw2ioQgyoW4fUA==
X-Sequence: 3976
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 10:30:18 +0200
Original-Message-Id: <87lilha86d.fsf@frosties.localnet>
Original-References: <CAN2fQM6PmfgkBspx1Js0yq8r2hbtd15mhvDXQ6tUcmAL46q=rw@mail.gmail.com>
<3C0F509D-8590-4D45-A586-83630088C7B5@pobox.com>
<CAPFanBEofozEj3dRVU_c9_J2LUSp1DH7X8R=02GBd8BriFoLFA@mail.gmail.com>
Content-Type: text/plain; charset=us-ascii