openlang

Client values requiring monomorphism

I'm new to Eliom and encounter The types of client values must be monomorphic from its usage or from its type annotation. This is the example I've got so far:

  let%server new_entry_form =
  let open Html.D in
  let field = Raw.input ~a:[a_input_type `Text] () in
  let submit = Raw.button ~a:[a_class ["button"]] [txt "add"] in
  ignore
  [%client
  let open Html.D in
  let open Js_of_ocaml_lwt.Lwt_js_events in
  let field = Html.To_dom.of_input ~%field in
  (Lwt.async @@ fun() ->
  clicks (Html.To_dom.of_element ~%submit)
  (fun _ _ ->
  let entered = field##value |> Js_of_ocaml.Js.to_string in
  add_entry {id="5";name=entered;description=""};
  Lwt.return_unit):unit
  )];

  div [
  field;submit
  ]

I'm guessing ~%field and ~%submit are the trouble. Why does this produce an error when it looks much like the tutorial code? Where have I gone wrong?

The conversation continues 2

Follow the reasoning
  1. Permalink

    An annotation on the client value resolves it:

      let _ : unit Lwt.t Eliom_client_value.t = [%client ...] in

    After that, access the value attribute rather than a method that doesn't exist:

      let entered = field##.value |> Js_of_ocaml.Js.to_string in

    Hope that's useful!

Other sides of the same question

  1. How can I subclass a class inside another class?

    Hi, In a package whose code is outside my control, there is a hierarchy of classes arranged as follows: I'm trying to add a w…

    Replies 1Latest activity scala
  2. Comparing have with let bindings in Lean4

    I've observed that these two expressions and behave identically. This also happens in theorem proofs. Are they interchangeabl…

    Replies 3Latest activity lean-4
  3. TypeScript Map initialization with string array entries

    I'm creating a Map whose entries each hold an array of strings. How can I declare its type and initialize it together in one…

    Replies 2Latest activity typescript