> 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 <hyw...@pobox.com> wrote:
>
> On Apr 26, 2012, at 3:36 PM, ocamllist.robertw...@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

Reply via email to