Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion functions not included in module signature #116

Open
jchavarri opened this issue Oct 14, 2020 · 1 comment
Open

Conversion functions not included in module signature #116

jchavarri opened this issue Oct 14, 2020 · 1 comment

Comments

@jchavarri
Copy link
Contributor

Input (.ml file):

include [%js:
module M: sig
  type t
end
]

Generates (simplified):

include (
  struct
    module M = struct
      type t = Ojs.t

      let rec (t_of_js : Ojs.t -> t) = fun x2 -> x2

      and (t_to_js : t -> Ojs.t) = fun x1 -> x1
    end
  end :
    sig
      module M : sig
        type t
      end
    end )

One has to include the conversion functions t_of_js and t_to_js manually on the signature, which is quite tedious. Maybe gen_js_api could include them as well there?

@mlasson
Copy link
Member

mlasson commented Oct 15, 2020

Yes I known it's tedious but currently [%js: ] behaves like the standalone tool; it does not rewrite the signature at all (ie. interfaces are not preprocessed: you could compile the .mli without preprocessing it and it should be a valid interface for the generated structure).

This design decision was taken a long time ago because it was convenient to integrate with ancient build systems.

With the advent of dune this maybe its time to change that (in particular, this may be needed to support ppxlib).

We could do a quick fix for the [%js: extension] but I prefer to wait at least for the ppxlib integration to take a decision.

@mlasson mlasson linked a pull request Feb 1, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants