0
let read_file path =
  In_channel.with_open_bin path In_channel.input_all

let solve input = input

let () =
  read_file "input.txt"
  |> solve
  |> print_endline

I am currently trying to run this code but keep running into unbound module In_channel error, I referred to similar threads, it seemed like the solution was to create a local switch and I installed core/bench/utop locally , I also added core as part of build config for the executable. Still it says unbound module. The current status of the folder is below, /dune does call core under libraries. The code is part of main.ml

I am using emacs, I dont know if that matters.

Current project folder setup

Thanks in advance.

2
  • I presume solve has some as of yet unimplemented purpose. Commented Dec 3, 2024 at 15:50
  • Minor style note: you can write In_channel.(with_open_bin path input_all) Commented Dec 3, 2024 at 15:51

1 Answer 1

1

The In_channel module was added to the standard library in OCaml 4.14 . You are probably using an older version of OCaml. You can upgrade to the latest stable version with

opam switch create 5.2.1
Sign up to request clarification or add additional context in comments.

2 Comments

It still says the same, currently my env variable is OPAMSWITCH = 5.2.1
Did you check that ocamlopt -v print the expected version? Did you build your code once locally (to initialize the LSP)? Your code snippet compiles without issue for me (even if you might want to remove the dependency on the core library).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.