* [Caml-list] Beginners Question for js_of_ocaml @ 2017-01-13 23:58 Helmut Brandl 2017-01-14 7:49 ` Nicolás Ojeda Bär 0 siblings, 1 reply; 5+ messages in thread From: Helmut Brandl @ 2017-01-13 23:58 UTC (permalink / raw) To: Caml List Hello List, I am trying to use js_of_ocaml to compile my ocaml project for the nodejs ecosystem. Since js_of_ocaml does not compile calls to the 'unix' library I have to call some javascript functions directly from ocaml. All I need is to be able to call the javascript functions - readdirSync - mkdirSync - rmdirSync - statSync and receive the results in ocaml. I have looked into the documentation and into the examples, but I have not found a way on how to do this. All examples are for use in the browser. Maybe its a stupid question and it is so simple that I, as a beginner in js_of_ocaml, just don't see it. Can anybody give me a hint? Thanks in advance. Regards Helmut ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Beginners Question for js_of_ocaml 2017-01-13 23:58 [Caml-list] Beginners Question for js_of_ocaml Helmut Brandl @ 2017-01-14 7:49 ` Nicolás Ojeda Bär 2017-01-14 18:16 ` Philippe Veber 2017-01-16 14:24 ` Helmut Brandl 0 siblings, 2 replies; 5+ messages in thread From: Nicolás Ojeda Bär @ 2017-01-14 7:49 UTC (permalink / raw) To: Helmut Brandl; +Cc: Caml List [-- Attachment #1: Type: text/plain, Size: 1447 bytes --] Hi Helmut, I am a js_of_ocaml beginner, but it sounds like you could do it using : Js.Unsafe.fun_call (Js.Unsafe.js_expr "readdirSync") [| .. args , wrapped with Js.Unsafe.inject .. |] You can look at the docs at https://ocsigen.org/js_of_ocaml/2.8.3/manual/bindings, especially under "Binding a JS function", where there is an example with the function "decodeURI". Cheers! Best wishes, Nicolas On Sat, Jan 14, 2017 at 12:58 AM, Helmut Brandl <helmut.brandl@gmx.net> wrote: > Hello List, > > I am trying to use js_of_ocaml to compile my ocaml project for the nodejs > ecosystem. Since js_of_ocaml does not compile calls to the 'unix' library I > have to call some javascript functions directly from ocaml. All I need is > to be able to call the javascript functions > > - readdirSync > - mkdirSync > - rmdirSync > - statSync > > and receive the results in ocaml. > > I have looked into the documentation and into the examples, but I have not > found a way on how to do this. All examples are for use in the browser. > Maybe its a stupid question and it is so simple that I, as a beginner in > js_of_ocaml, just don't see it. > > Can anybody give me a hint? Thanks in advance. > > Regards > Helmut > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > [-- Attachment #2: Type: text/html, Size: 2459 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Beginners Question for js_of_ocaml 2017-01-14 7:49 ` Nicolás Ojeda Bär @ 2017-01-14 18:16 ` Philippe Veber 2017-01-16 14:30 ` Helmut Brandl 2017-01-16 14:24 ` Helmut Brandl 1 sibling, 1 reply; 5+ messages in thread From: Philippe Veber @ 2017-01-14 18:16 UTC (permalink / raw) To: Nicolás Ojeda Bär; +Cc: Helmut Brandl, Caml List [-- Attachment #1: Type: text/plain, Size: 1962 bytes --] Also note there are bindings to nodejs for js_of_ocaml [1] developped by Edgar Aroutiounian. I have not checked if the functions you need are in there, but if they're not, you could contribute them to this project. Hope that helps, philippe. [1] https://github.com/fxfactorial/ocaml-nodejs 2017-01-14 8:49 GMT+01:00 Nicolás Ojeda Bär <nicolas.ojeda.bar@lexifi.com>: > Hi Helmut, > > I am a js_of_ocaml beginner, but it sounds like you could do it using : > > Js.Unsafe.fun_call (Js.Unsafe.js_expr "readdirSync") [| .. args , > wrapped with Js.Unsafe.inject .. |] > > You can look at the docs at https://ocsigen.org/js_of_ > ocaml/2.8.3/manual/bindings, especially under > "Binding a JS function", where there is an example with the function > "decodeURI". > > Cheers! > > Best wishes, > Nicolas > > > > > > On Sat, Jan 14, 2017 at 12:58 AM, Helmut Brandl <helmut.brandl@gmx.net> > wrote: > >> Hello List, >> >> I am trying to use js_of_ocaml to compile my ocaml project for the nodejs >> ecosystem. Since js_of_ocaml does not compile calls to the 'unix' library I >> have to call some javascript functions directly from ocaml. All I need is >> to be able to call the javascript functions >> >> - readdirSync >> - mkdirSync >> - rmdirSync >> - statSync >> >> and receive the results in ocaml. >> >> I have looked into the documentation and into the examples, but I have >> not found a way on how to do this. All examples are for use in the browser. >> Maybe its a stupid question and it is so simple that I, as a beginner in >> js_of_ocaml, just don't see it. >> >> Can anybody give me a hint? Thanks in advance. >> >> Regards >> Helmut >> >> >> -- >> Caml-list mailing list. Subscription management and archives: >> https://sympa.inria.fr/sympa/arc/caml-list >> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >> Bug reports: http://caml.inria.fr/bin/caml-bugs >> > > [-- Attachment #2: Type: text/html, Size: 3409 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Beginners Question for js_of_ocaml 2017-01-14 18:16 ` Philippe Veber @ 2017-01-16 14:30 ` Helmut Brandl 0 siblings, 0 replies; 5+ messages in thread From: Helmut Brandl @ 2017-01-16 14:30 UTC (permalink / raw) To: Philippe Veber; +Cc: Caml List, Nicolás Ojeda Bär [-- Attachment #1: Type: text/plain, Size: 2147 bytes --] Sounds interesting. On Jan 14, 2017 12:16 PM, "Philippe Veber" <philippe.veber@gmail.com> wrote: > Also note there are bindings to nodejs for js_of_ocaml [1] developped by > Edgar Aroutiounian. I have not checked if the functions you need are in > there, but if they're not, you could contribute them to this project. > > Hope that helps, > philippe. > > [1] https://github.com/fxfactorial/ocaml-nodejs > > 2017-01-14 8:49 GMT+01:00 Nicolás Ojeda Bär <nicolas.ojeda.bar@lexifi.com> > : > >> Hi Helmut, >> >> I am a js_of_ocaml beginner, but it sounds like you could do it using : >> >> Js.Unsafe.fun_call (Js.Unsafe.js_expr "readdirSync") [| .. args , >> wrapped with Js.Unsafe.inject .. |] >> >> You can look at the docs at https://ocsigen.org/js_of_ocam >> l/2.8.3/manual/bindings, especially under >> "Binding a JS function", where there is an example with the function >> "decodeURI". >> >> Cheers! >> >> Best wishes, >> Nicolas >> >> >> >> >> >> On Sat, Jan 14, 2017 at 12:58 AM, Helmut Brandl <helmut.brandl@gmx.net> >> wrote: >> >>> Hello List, >>> >>> I am trying to use js_of_ocaml to compile my ocaml project for the >>> nodejs ecosystem. Since js_of_ocaml does not compile calls to the 'unix' >>> library I have to call some javascript functions directly from ocaml. All I >>> need is to be able to call the javascript functions >>> >>> - readdirSync >>> - mkdirSync >>> - rmdirSync >>> - statSync >>> >>> and receive the results in ocaml. >>> >>> I have looked into the documentation and into the examples, but I have >>> not found a way on how to do this. All examples are for use in the browser. >>> Maybe its a stupid question and it is so simple that I, as a beginner in >>> js_of_ocaml, just don't see it. >>> >>> Can anybody give me a hint? Thanks in advance. >>> >>> Regards >>> Helmut >>> >>> >>> -- >>> Caml-list mailing list. Subscription management and archives: >>> https://sympa.inria.fr/sympa/arc/caml-list >>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >>> Bug reports: http://caml.inria.fr/bin/caml-bugs >>> >> >> > [-- Attachment #2: Type: text/html, Size: 3883 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Beginners Question for js_of_ocaml 2017-01-14 7:49 ` Nicolás Ojeda Bär 2017-01-14 18:16 ` Philippe Veber @ 2017-01-16 14:24 ` Helmut Brandl 1 sibling, 0 replies; 5+ messages in thread From: Helmut Brandl @ 2017-01-16 14:24 UTC (permalink / raw) To: Nicolás Ojeda Bär; +Cc: Caml List [-- Attachment #1: Type: text/plain, Size: 1897 bytes --] Hello Nicolas, thanks for the hint. It works nearly as you explained. I have to get first the fs object and then make a method call and not a function call. As you explained there is all information necessary in the documentation. I just did not find it in my first attempt. Regards Helmut On Jan 14, 2017 1:49 AM, "Nicolás Ojeda Bär" <nicolas.ojeda.bar@lexifi.com> wrote: Hi Helmut, I am a js_of_ocaml beginner, but it sounds like you could do it using : Js.Unsafe.fun_call (Js.Unsafe.js_expr "readdirSync") [| .. args , wrapped with Js.Unsafe.inject .. |] You can look at the docs at https://ocsigen.org/js_of_ ocaml/2.8.3/manual/bindings, especially under "Binding a JS function", where there is an example with the function "decodeURI". Cheers! Best wishes, Nicolas On Sat, Jan 14, 2017 at 12:58 AM, Helmut Brandl <helmut.brandl@gmx.net> wrote: > Hello List, > > I am trying to use js_of_ocaml to compile my ocaml project for the nodejs > ecosystem. Since js_of_ocaml does not compile calls to the 'unix' library I > have to call some javascript functions directly from ocaml. All I need is > to be able to call the javascript functions > > - readdirSync > - mkdirSync > - rmdirSync > - statSync > > and receive the results in ocaml. > > I have looked into the documentation and into the examples, but I have not > found a way on how to do this. All examples are for use in the browser. > Maybe its a stupid question and it is so simple that I, as a beginner in > js_of_ocaml, just don't see it. > > Can anybody give me a hint? Thanks in advance. > > Regards > Helmut > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > [-- Attachment #2: Type: text/html, Size: 3385 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-01-16 14:30 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-01-13 23:58 [Caml-list] Beginners Question for js_of_ocaml Helmut Brandl 2017-01-14 7:49 ` Nicolás Ojeda Bär 2017-01-14 18:16 ` Philippe Veber 2017-01-16 14:30 ` Helmut Brandl 2017-01-16 14:24 ` Helmut Brandl
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox