I am running into another silly error. I can not figure out what I am doing wrong.
Here is a Minimal Failure Case:
open Js_of_ocaml
let _ = File.make_blob ""
Error:
File "Code.ml", line 3, characters 8-22:
3 | let _ = File.make_blob ""
^^^^^^^^^^^^^^
Error: Unbound value File.make_blob
Dune:
(library
(name f_msg)
(inline_tests)
(libraries core_kernel js_of_ocaml js_of_ocaml-lwt)
(preprocess
(pps ppx_jane ppx_blob ppx_inline_test ppx_assert js_of_ocaml-ppx)))
opam list shows 5.2.0 installed
What am I doing wrong ?
Location of function: js_of_ocaml/file.mli at master · ocsigen/js_of_ocaml · GitHub
nojb
May 30, 2023, 11:12am
2
zeroexcuses:
What am I doing wrong ?
File.make_blob
is a type constructor, not a value.
Cheers,
Nicolas
1 Like
Followup:
Minimal error code:
open Js_of_ocaml
let _ = Dom_html._URL##.createObjectURL ""
Error:
3 | let _ = Dom_html._URL##.createObjectURL ""
^^^^^^^^^^^^^
Error: Unbound value Dom_html._URL
The coded I want to call looks like:
class type _URL =
object
method createObjectURL : #File.blob t -> js_string t meth
method revokeObjectURL : js_string t -> unit meth
end
method oncached : (applicationCache t, event t) event_listener prop
method onobsolete : (applicationCache t, event t) event_listener prop
inherit eventTarget
end
class type _URL =
object
method createObjectURL : #File.blob t -> js_string t meth
method revokeObjectURL : js_string t -> unit meth
end
class type window =
object
inherit eventTarget
method document : document t readonly_prop
This is in file dom_html.ml, thus module name Dom_html.
Class name _URL. What am I doing wrong ?
nojb
May 30, 2023, 1:42pm
4
_URL
is not a class, it is a class type. In any case, it is not a value. I suggest you read OCaml - Objects in OCaml to learn the basics of objects in OCaml.
Cheers,
Nicolas
1 Like
Found the solution:
let _ : Dom_html._URL Js.t = Dom_html.window##._URL ;