Quantcast
Viewing all articles
Browse latest Browse all 521

Basic problem with Dune and .mli files

Hi,

I’m new to Dune and OCaml, and I have the fundamental problem that the content of a .mli file is not visible from the corresponding .ml file. I must be missing something very basic.

Minimal example:

dune init proj myproj

(No changes to any dune files after this.)

Add files lib/foo.ml and lib/foo.mli

(* lib/foo.mli *)
module type Foo_sig = sig
	val content : string
end;;
(* lib/foo.ml *)
module Foo : Foo_sig = struct
	let content = "Success!";;
end;;

Replace the code in bin/main.ml

(* bin/main.ml *)
open Myproj.Foo

let () = print_endline Foo.content

This fails with “unbound module type Foo_sig”. If I copy the code of foo.mli into foo.ml, it works perfectly.

4 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 521

Trending Articles