darioteixeira / pgocaml

PG'OCaml provides an interface to PostgreSQL databases for OCaml applications. It uses Camlp4 to extend the OCaml syntax, enabling one to directly embed SQL statements inside the OCaml code.
Other
158 stars 36 forks source link

document how to use Lwt with PGOCaml #5

Open mk270 opened 10 years ago

mk270 commented 10 years ago

https://github.com/mk270/postgres-lwt-example/blob/master/main.ml

bruce-ricard commented 7 years ago

Is it possible to use lwt AND the syntax extension at the same time?

ghuysmans commented 7 years ago

I'm a bit late but maybe it could help someone... If you use the camlp4 extension (provided by lwt.syntax), you can write lwt x = ... in instead of lwt.ppx's let%lwt x = ... in.

Using ocamlfind, you can build your program this way:

ocamlfind ocamlopt -package pgocaml.syntax,lwt.syntax,lwt.unix -syntax camlp4o -linkpkg test.ml
mk270 commented 7 years ago

I'm still interested in the use of postgres with ocaml and lwt, so would be happy to help out with improving the docs. My "OCaml week" is early December - I'll get in touch then

ghuysmans commented 7 years ago

Maybe the most complicated thing in there is how the build process works (opam packages, ocamlfind packages, camlp4/ppx...). I'm not really sure whether this kind of explanation belongs to this particular project.