Writing some pgocaml/database related code in a _db.ml file (as required), I realized that I had difficulties exposing a simple function from another file. Here is what I tried:
(* inside a function in a _db.ml file: *) let hstore_opt = Utils.one_of_opt_db hstores_opt in ... (* inside utils.eliom: *) [%%shared let filter_none_db l = let rec skip_none acc_l = function | None :: tl -> skip_none acc_l tl | Some e :: tl -> skip_none (e::acc_l) tl |  -> acc_l in skip_none  l let one_of_opt_db l = match filter_none_db l with | a :: _ -> Some a |  -> None ]
It lead me to following error message:
File "administrative_book_db.ml", line 240, characters 19-38: 240 | let hstore_opt = Utils.one_of_opt_db hstores_opt in ^^^^^^^^^^^^^^^^^^^ Error: Unbound value Utils.one_of_opt_db Makefile.os:235: recipe for target '_server/administrative_book_db.cmo' failed
And it is the same if I replace
[%%shared ... ] by
[%%server ... ] (and even if I had the same declarations in a
[%%client ... ] block just after).
It is very surprising to me for three reasons:
1/ as in ocsigen-start demo_pgocaml_db.ml, this file starts with
open Os_db and uses function
full_transaction_block without any problem.
2/ I expose a lot of types declared in shared section from another module without problem
3/ I exposed already a log function from utils.eliom. This function is a bit special, I wrote it this way so that I could called it the same way from client and server side:
let%server log s = let s = " # log: "^s in let%lwt _ = Lwt_unix.write_string Lwt_unix.stdout (s) 0 (String.length s) in Lwt.return () let%server log_from_client = Eliom_client.server_function [%json: string] (Os_session.Opt.connected_rpc (fun userid s -> log s)) let%client log_from_client = ~%log_from_client let%client log = ~%log_from_client
(I tried to expose one_of_opt_db the same way with an rpc, but I could not serialize polymorphic type 'a option list to json)
I can of course simply write those functions inside the _db.ml file, but I find it a bit frustrating to do this way if I want to split this file later.
What do you think I am doing wrong?
(I use eliom 6.11.0 and ocsigen-start 2.16.1)
Thanks a lot for your help!