dune-ocaml : No implementations provided for the following modules:

Hello All,

I tried to compile an OCaml code with Dune but got the following error: Error: No implementations provided for the following modules:
CallccBp referenced from bin/.CallccTest.eobjs/native/dune__exe__CallccTest.cmx

by executing the command : $ dune build

My project hierarchy is as follows:

callcc/
bin/
callccTest.ml
dune
[
(executable
(name callccTest)
(libraries CallccBp))
]
lib/
CallccBp.mli
dune
[
(library
(name CallccBp)
(modules_without_implementation CallccBp))
]
test/
callccTest.ml
dune [
(test
(name callccTest))
]

callcc.opam
dune-project

How can I solve this problem?

Thank you.

What is the content of callccBp.mli? Does it define any exception?

Cheers,
Nicolas

callccBp.mli
type 'a cont
val callcc: ('a cont → 'a) → 'a
val throw: 'a cont → 'a → 'b

callccTest.ml
open callccBp
let now () =
let s = ref None in
callcc (fun k → s := Some k);
s

let past_travel_to date =
match !date with
| None → assert false
| Some date → throw date ()

let cake = ref Cake let eat () = assert (!cake = Cake);
Printf.printf “I am eating the cake! Miamee!\n”;
cake := `NoMoreCake

let _ =
let t = now () in
Printf.printf “I am in front of the cake\n.”;
eat ();
past_travel_to t

The module CallccBp declares values callcc and throw, so it needs an implementation: you cannot use modules_without_implementation for such modules. You must provide an implementation.

Cheers,
Nicolas

Without the deposit
(modules_without_implementation callccBp)

I have the following error: File “lib/dune”, line 1, characters 0-26:
1 | (library
2 | (name CallccBp))
Error: Some modules don’t have an implementation.
You need to add the following field to this stanza:

(modules_without_implementation callccBp)

You need to write down a callccBp.ml file

type 'a cont = ...
let callcc = ...
let throw = ...

What is the general context? It is a bit surprising that you ended up writing a library without knowing what are mli fles.

When I first tried the program it gave me the signature error and I didn’t know there was another solution.

With :
type 'a cont
let callcc = ('a cont → 'a) → 'a
let throw = 'a cont → 'a → 'b

I have error :
File “bin/CallCCTest.ml”, line 2, characters 14-15:
2 | let callcc = ('a cont → 'a) → 'a
^
Error: Syntax error: operator expected.

This is not valid OCaml code: a type is not an implementation.

At this point, it is probably better to try to take some distance and take the time to contextualize what you are trying to do.

Thank you for your help.
I tried to transfer the code from Ocaml to Coq, I found the coq-of-ocaml tool. for this the code must be compiled with dune.