-
Notifications
You must be signed in to change notification settings - Fork 448
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
Using existing ocaml packages #706
Comments
you don't need change the build system, only a build script would be good enough. bsc -bs-files *.ml *.mli |
Are there any plans to automate this for users? Like, getting package from opam and automatically compile it to cmj, putting into right place, etc? Right now, forking package doesn't look very appealing, imo. |
@little-arhat you should check with @chenglou , they are working on npm-ml which might automate such process |
I think the good way to handle this is to teach |
Does bsc support lwt? When I add this
I tried adding this line to my bsc call:
(With package misspelled.)
Any ideas? I'd really like to be able to use the |
@chrisdavies that's what this issue is about — currently, to use existing ocaml package, you have to compile it yourself, using |
@chrisdavies we have some bindings for promise in case you missed it (with >>= operator): https://github.com/bloomberg/bucklescript-addons/blob/master/bindings/bs-promise/README.md |
@bobzhang Looking at the source for the link you sent, I don't see a definition for By the way, so far, I'm really impressed with Bucklescript. |
@little-arhat Thanks. It wasn't clear to me what the answer was, even though I did see that lwt was part of the question. :) Now it's clear. |
Interesting. Hadn't looked at the Thanks! |
(>>=) is a plain function, you can redefine it any way you like! |
This issue that I created would make it trivial to use any existing OCaml package (as long as it doesn't require something like C stubs) |
Where |
It's looking for a package published on npm |
No way to use an ocaml pkg install using opam? |
@cchantep checkout the new build system, it is really easy to convert an existing ocaml package to npm using |
Thanks for the advice. I don't see the doc about how to make an existing package available in this way. Can you indicate a link to such doc? |
Typically in a multi-module project, I would like to re-use some code from a server-side/ocaml module (let call it
|
how about this issue ? Can i use bsb compile janes core library? thanks. |
@bobzhang is there any progress on this issue? |
/me is also curious about bringing in PPX's from opam... |
What's required to make progress on this? It became a huge pain point after adopting BuckleScript for backend services. I hope it can be prioritized as soon as the compiler is upgraded to support OCaml 4.06.1. |
|
Looking at the bsb-native README, it looks like it's possible to include ocaml libs using the |
I'm also really wanting to share code between server (reason native) and client (reason/react) |
For depending on ppx's, esy could be used if this issue is addressed. For being able to compile arbitrary opam packages using BuckleScript, that's a whole other issue which I don't know the answer to. That one seems really hard given the architectural decisions of bucklescript. |
Let me recap a bit. BuckleScript is OCaml. It should be able to compile any idiomatic OCaml code. If it can't, that's a bug (@bobzhang please correct me if I'm wrong). As such, BuckleScript inherently supports using any existing OCaml package (by which I mean collection of At this point, let me just emphasize that this is OK. BuckleScript is doing something different from opam and dune. It's targeting JS devs to try to onboard them to a safe, sound static type system and compiler which we all happen to think is the best around. It's not necessarily targeting the existing opam/dune community, that is already well-served by JSOO. If you want to depend heavily on opam packages, you probably want JSOO. Given the above situation, if you want to reuse opam packages in BuckleScript, you will need to explore custom solutions. I hate to say it, but you might even need to vendor the packages with something like git submodules. That's the situation right now. Edit: let me just add that if you want to share code between backend and frontend in the same repo, there's nothing stopping that today–just put the shared code somewhere both build systems can find them. See https://github.com/atongen/setml for a great example of this. |
There are some technical challenges to support OPAM packages. |
@yawaramin This is not what people typically mean when they say "package" though. In fact, they don't really even mean opam package. What they usually mean is a compiled set of source files that have been organized into an output with an ocamlfind config. @bobzhang I think the easiest path would be to somehow allow bs compiler to consume ocaml packages that were compiled with jsoo. It might not be the highest priority, but it would be good to think about longer term. If the two systems can agree on a convention for representation (or can be configured to agree) then it might be doable. BuckleScript wouldn't need to care how those were compiled, it can perhaps trust that the representation is correct given a signature file or something. |
@jordwalke from my limited knowledges of jsoo. You can't even share the same type between 2 separate build of jsoo |
I don't understand what you mean. Can you maybe give a concrete example ? |
I just re-read all the comments on this issue. I think we should close it; from @bobzhang 's comments it hasn't been on the BuckleScript roadmap to support opam packages in an automated way. If someone would like to come up with a technical proposal (or even better, PR) that's great but in the meantime this is spinning in place :-) |
Ok yeah, let's close this for now. There are similar, easier issues we can solve to advance this one too |
Hi,
So, I've seen http://bloomberg.github.io/bucklescript/Manual.html#_build_ocaml_library_as_a_npm_package but it's unclear, how I can use existing OCaml package (say, containers or Lwt)? Should I fork them, change Makefiles and convert them to npm modules using
bsc
? Or there is better way?Thanks
The text was updated successfully, but these errors were encountered: