Quantcast
Channel: Active questions tagged ocaml - Stack Overflow
Viewing all articles
Browse latest Browse all 595

Unbound value error for custom module function

$
0
0

I’m working on a project in OCaml using Dune, and I’m encountering an “Unbound value” error for a function defined in a custom module. I’ve ensured that the module is correctly defined and imported, but the error persists.

Relevant files:

lib/markdown.ml

module Markdown = struct  open Omd  let convert_markdown_to_html content =    content |> Omd.of_string |> Omd.to_htmlend

lib/lib.ml

module Markdown = Markdownmodule Template = Templatemodule SiteConfig = SiteConfigmodule Generator = Generator

lib/generator.ml

open Coreopen Core_unixmodule Generator = struct  let generate_site config =    let dh = Core_unix.opendir "content/" in    let rec read_all dh acc =      match Core_unix.readdir_opt dh with      | None -> List.rev acc      | Some entry -> read_all dh (entry :: acc)    in    let markdown_files = read_all dh [] in    Core_unix.closedir dh;    List.iter markdown_files ~f:(fun file ->      let input_path = "content/" ^ file in      let output_path = "output/" ^ (Filename.chop_suffix file ".md") ^ ".html" in      let content = In_channel.read_all input_path in      let html_content = Markdown.convert_markdown_to_html content in      let template = In_channel.read_all "templates/default.html" in      let full_content = Template.render_template template html_content in      Out_channel.write_all output_path ~data:full_content    )end

lib/dune

(library (name ocamlpress) (public_name ocamlpress) (libraries str yojson omd core core_unix))

bin/dune

(executable (public_name ocamlpress) (name main) (libraries ocamlpress omd cohttp lwt cmdliner))

Error Message:

When I run dune build, I get the following error:

File "lib/generator.ml", line 28, characters 25-58:28 |       let html_content = Markdown.convert_markdown_to_html content in                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Error: Unbound value Markdown.convert_markdown_to_html

I’ve tried cleaning and rebuilding the project using dune clean and dune build, but the error persists.The dune and dune-project files are correctly set up according to Dune documentation.I’m using OCaml version 4.12.0 and Dune version 2.9.1.

Why am I getting the “Unbound value” error for Markdown.convert_markdown_to_html, and how can I resolve this issue?


Viewing all articles
Browse latest Browse all 595

Trending Articles