ocsigen / js_of_ocaml

Compiler from OCaml to Javascript.
http://ocsigen.org/js_of_ocaml/
Other
963 stars 188 forks source link

[BUG] [documentation] Js_of_ocaml online toplevel given by the documentation doesn't work #1741

Closed njaros closed 3 days ago

njaros commented 3 days ago

Describe the bug
I'm learning Ocsigen thanks of the official documentation,
I'm on the Js_of_ocaml section of https://ocsigen.org/tuto/latest/manual/basics page
As the documentation suggest me, I tried to use the Js_of_ocaml online in this [Toplevel running in the browser] (https://ocsigen.org/js_of_ocaml/latest/manual/files/toplevel/index.html)

but when I write Dom_html.ducument;; I get this error : Line 1, characters 0-17:
Error: Unbound module Dom_html

I tried to type #require "Js_of _ocaml" or #use "Js_of_ocaml" to make it works but it seems to be pointless.

Expected behavior I expected to recover this line :

Versions Version of packages used to reproduce the bug OCaml version 5.1.1
Compiled with Js_of_ocaml version 5.8.2+519dc5c

njaros commented 3 days ago

I'm sorry I don't know how to add the tag [documentation] ...

OlivierNicole commented 3 days ago

What about:

open Js_of_ocaml;;
njaros commented 3 days ago

thanks :) I don't anderstand yet the difference between #require or #use or open So much documentation to read in Ocaml ...

njaros commented 3 days ago

I close

OlivierNicole commented 3 days ago

#require does not exist as far as I know. #use executes all toplevel statements of a .ml file.

And open is of a different nature, since it is not a toplevel primitive but a keyword of the language. So unlike #use, it can be used in any OCaml file (not just in the toplevel). open M brings all identifiers exposed by module M into the global scope. https://ocaml.org/manual/5.2/modules.html#sss:mexpr-open