By default dune will use all the .ml/.re files in the same directory as the dune file.
So if I understand well, in the main.ml I should be able to open BooleanFormulae.Parser or open BooleanFormulae.Types.
However, dune build main.exe complains:
File "main.ml", line 2, characters 5-27:
2 | open BooleanFormulae.Parser
^^^^^^^^^^^^^^^^^^^^^^
Error: Unbound module BooleanFormulae.Parser
Just referring to Parser in main.ml doesn’t work either.
What should I do? And is my project globally well structured?
in the test/test.ml, I cannot refer to the values in types.ml (included in the booleanFormulae.mli interface) [Unbound constructor …], but I can do it in the main.ml file.
I might be wrong, but the message is
“unbound module BooleanFormulae.Parser”, not “unbound module BooleanFormulae”
Can we see your booleanFormular.mli ?
But also, your library is called BooleanFormulae and your file is BooleanFormulae
I’ve had issues with first letter case sensitivity in the past, try to have them matching
Hi, thank you for trying to help. Change the case of my file to uppercase doesnt seem to get things better.
Here is my BooleanFormulae.mli:
open Types
type decTree = DecLeaf of bool | DecRoot of string * decTree * decTree
module VarsSet :
sig
(* set signature *)
end
val getVars : tformula -> VarsSet.t
type env
val empty_env : env
val env_of_bindings : (string * bool) list -> env
val evalFormula : env -> tformula -> bool
val buildDecTree : tformula -> decTree
type bddGraph
val buildBdd : tformula -> bddGraph
val isTautology : tformula -> bool
val areEquivalent : tformula -> tformula -> bool
module Dot :
sig
type style = Red | Dashed | Bold
type elt = Node of (int * string) | Vertex of (int * int)
type digraph
val empty : digraph
val join : digraph -> digraph -> digraph
val addWithStyle : elt -> style list -> digraph -> digraph
val add : elt -> digraph -> digraph
val join_in_bracket : string list -> string
val show : string -> digraph -> string
end
val bddToDot : bddGraph -> Dot.digraph
val decTreeToDot : int -> decTree -> int * Dot.digraph
Ah ! I understand what’s happening now
Didn’t read your tree properly
When you have a file in your directory that has the same name as your library (booleanFormulae here), dune creates a library from this file.
Meaning, in booleanFormulae.ml you need:
I think it would be helpful if you could upload a small sample project with this issue. We could examine it and figure out what should be changed to make it work.
I don’t know how yet to specify what package install with opam (like the “requirements.txt” in python or “package.json” with npm). The dependencies are: ounit2 and angstrom.
That’s in a .mli file. To include the contents of another module, the corresponding signature item is include module type of Types. To expand a bit on this:
Types is a module.
its (inferred) module type is module type of Types
in mli files, include expects a module type (which does not necessarily correspond to a module in particular, which is why you can do include Set.OrderedType)