caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Helmut Brandl <helmut.brandl@gmx.net>
To: caml-list@inria.fr
Subject: Re: [Caml-list] js_of_ocaml with node
Date: Wed, 29 Apr 2015 17:03:21 -0500	[thread overview]
Message-ID: <55415529.2010802@gmx.net> (raw)
In-Reply-To: <553F6C57.50407@zoho.com>

Thanks to all for the hints.

I think I have to dig into the documentation of js_of_ocaml to resolve 
the problem.

Regards
Helmut

On 04/28/2015 06:17 AM, Drup wrote:
> You can go one step further here and expose lwt threads instead. It 
> could be done automatically too, since transforming callbacks into lwt 
> thread is always done the same way.
>
> Le 28/04/2015 09:53, Alain Frisch a écrit :
>> On 04/28/2015 12:41 AM, Daniel Bünzli wrote:
>>> Le mardi, 28 avril 2015 à 00:03, Alain Frisch a écrit :
>>>> val mkdir: string -> int -> unit
>>>> [@@js.global "fs.mkdirAsync"]
>>>
>>> That should be "fs.mkdirSync".
>>
>> Indeed!
>>
>>> Just curious, how would the binding to the async fs.mkdir look like ?
>>
>> Something like:
>>
>> val mkdir_async: string -> int -> (js_exn option -> unit) -> unit
>>   [@@js.global "fs.mkdir"]
>>
>> assuming some predefined bindings for js_exn.  (One could also decide 
>> to bind JS exception to OCaml's exn type, but the gain is not clear.)
>>
>> There are other possible variations, such as making the mode optional:
>>
>> val mkdir_async:
>>     string ->
>>     ?mode:(int[@js.default 0o777]) ->
>>     (js_exn option -> unit) ->
>>     unit
>>   [@@js.global "fs.mkdir"]
>>
>>
>> Here js.default forces the default value for the optional mode 
>> argument.  Without it, a missing value will send an `undefined` as 
>> the second argument (I don't know if fs.mkdir would be happy with 
>> it).  This is currently not supported, but one could also extend the 
>> tool to allow:
>>
>> val mkdir_async:
>>     string ->
>>     ?mode:(int[@js.drop_if_missing]) ->
>>     (js_exn option -> unit) -> unit
>>   [@@js.global "fs.mkdir"]
>>
>> so that the second argument is dropped in the JS call if not provided 
>> (but I don't see how to support that for OCaml callbacks in full 
>> generality, since the function needs to check the type of arguments 
>> to decide how to interpret them).
>>
>>
>> Alain
>>
>
>
>


  reply	other threads:[~2015-04-29 22:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-27 20:32 Helmut Brandl
2015-04-27 21:02 ` Sébastien Dailly
2015-04-27 21:16   ` Helmut Brandl
2015-04-28  7:08     ` Sébastien Dailly
2015-04-27 21:11 ` Daniel Bünzli
2015-04-27 22:03 ` Alain Frisch
2015-04-27 22:41   ` Daniel Bünzli
2015-04-28  7:53     ` Alain Frisch
2015-04-28  8:11       ` Alain Frisch
2015-04-28 11:17       ` Drup
2015-04-29 22:03         ` Helmut Brandl [this message]
2015-04-29 22:49           ` Mauricio Fernández

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=55415529.2010802@gmx.net \
    --to=helmut.brandl@gmx.net \
    --cc=caml-list@inria.fr \
    /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).