LPCIC / elpi

Embeddable Lambda Prolog Interpreter
GNU Lesser General Public License v2.1
290 stars 36 forks source link

type equality from Elpi to Elpi_parser #277

Open cb-wells opened 1 week ago

cb-wells commented 1 week ago

Hello, thanks for this great project. Much of the setup is new to me, so this issue might have a simple resolution. I’m trying to add a new REPL command that iterates through the declarations of a parsed program.

List.iter (fun (d : Ast.Program.decl) -> … [[some printing]] … ) p;

But it doesn’t seem to recognize the type equality: “p has type API.Ast.program, but expected type Ast.Program.decl list”

I assume this is because API is in Elpi, while Ast is in Elpi_parser; somehow the equality is not working across packages. I could clone and build the whole project with my own; but there is probably a simpler solution. Any help is appreciated.

cb-wells commented 1 week ago

A small test program compiles with dune, with (libraries elpi elpi.parser). This links the modules to the program, but not to each other: within API.ml, there is the error “unbound module Elpi_parser”; and the equality “type program = Ast.Program.t” has a similar error. So, I assume this is probably an issue with the dune build.

Please let me know if I should provide more information. Thank you.

gares commented 1 week ago

Hello, there is no API for that. What I suggest is that you temporarily remove the private_modules directive in src/dune then edit src/elpi.ml so to expose all modules in Internal and finally use Elpi.Internal.Whatever you like.

You could also give me a pointer to your code so that I see exactly what you need.