Questions tagged [js-of-ocaml]

Js_of_ocaml is a compiler from OCaml bytecode to JavaScript, making it possible to run OCaml programs in a web browser.

Features

  • The whole language and most of the standard library are supported.
  • The compiler is easy to install: it only depends on Findlib and optionally .
  • The generated code is independent of Eliom and the Ocsigen server. You can use it with any web server.
  • You can use a standard installation of OCaml to compile your programs. In particular, you do not have to recompile a library to use it with Js_of_ocaml. You just have to link your program with a specific library to interface with browser APIs.

Useful resources

66 questions
0
votes
1 answer

Wrap an OCaml function that receives a JS object (record)

I want to write a very simple function in OCaml, and wrap it to make a JS function jsGet by js_of_ocaml, such that jsGet could take a JS object (or record) as input. I tried the following code: \\ in Home.js function testJsGet () { var input =…
SoftTimur
  • 5,630
  • 38
  • 140
  • 292
0
votes
1 answer

Wrap an OCaml function that returns a record

I have defined an OCaml function manipulate: string -> string. And I wrap it to make a JS function jsManipulate: let () = Js.Unsafe.global##.jsManipulate := Js.wrap_callback (fun s -> Js.string (manipulate (Js.to_string s))) Now, I want to…
SoftTimur
  • 5,630
  • 38
  • 140
  • 292
0
votes
1 answer

How to call a js_of_ocaml method?

I have a one-line js_of_ocaml program: Dom_html.window##scroll 100 100 ; Which fails with the error: File "tests/test_scrolling.ml", line 2, characters 0-23: Error: This expression has type int -> int -> unit Js.meth but an expression was…
Lyn Headley
  • 11,368
  • 3
  • 33
  • 35
0
votes
1 answer

How to trigger and handle a click event?

In the following code, I try to handle a click event on a checkbox. I expect to see the word "hello" printed in the javascript console, but instead I see nothing. How can I modify the code to get the print statement to execute? let…
Lyn Headley
  • 11,368
  • 3
  • 33
  • 35
0
votes
2 answers

Updating html slider attribute but not visible in the page

I have a html slider and I want to dynamically change the position of the cursor on the slider. Look at here my jsfiddle demo : http://jsfiddle.net/8DCS6/
alifirat
  • 2,899
  • 1
  • 17
  • 33
0
votes
2 answers

Can js_of_ocaml compile in-memory data-structures from the OCaml compiler?

Seeing as both the OCaml compiler and js_of_ocaml are written in OCaml, it seems reasonable (to me) that I should be able to write a wrapper that uses: the OCaml compilerlibs to compile OCaml source into, say Instruct.instruction list (using…
ngunn
  • 1
1 2 3 4
5