From 3c1f6ba5d89a9928ffbe1d94396d628ffa89f953 Mon Sep 17 00:00:00 2001 From: Marcos Magueta Date: Wed, 7 Oct 2026 23:28:50 -0300 Subject: scratch root for testing with subsystems explorer --- lib/Scratch.ml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lib/Scratch.ml (limited to 'lib/Scratch.ml') diff --git a/lib/Scratch.ml b/lib/Scratch.ml new file mode 100644 index 0000000..0779db3 --- /dev/null +++ b/lib/Scratch.ml @@ -0,0 +1,23 @@ +module LMDB = Backend.Storage.LMDB +module I = Kernel.Initialization.Make (LMDB) + +let rec remove path = + if Sys.is_directory path then begin + Array.iter (fun name -> remove (Filename.concat path name)) (Sys.readdir path); + Sys.rmdir path + end + else Sys.remove path + +let root ?(evaluators = ["fol", Evaluators.FOL.make ()]) () = + let open Utilities.Result in + let directory = Filename.temp_dir "rnt-scratch" "" in + let* connection = + Sexplib.Sexp.( + List [Atom "lmdb"; List [Atom "path"; Atom directory]; List [Atom "mode"; Atom "420"]] ) + |> Concepts.Configuration.term_of_sexp + |> LMDB.connect + in + at_exit (fun () -> + LMDB.disconnect connection; + try remove directory with Sys_error _ -> () ); + I.initialize ~evaluators connection -- cgit v1.2.3