Real World Ocaml Book Example won't compile

Hi Im trying to run a larger project and am struggling with this example:

open Core
open Core_unix

let do_hash file =
  Md5.digest_file_blocking file |> Md5.to_hex |> print_endline

let command =
  Command.basic
    ~summary:"Generate an MD5 hash of the input data"
    ~readme:(fun () -> "More detailed information")
    Command.Param.(
      map
        (anon ("filename" %: string))
        ~f:(fun filename () -> do_hash filename))

let () = Command_unix.run ~version:"1.0" ~build_info:"RWO" command

Getting Error: Unbound module Command_unix. Anyone point me in the correct direction. Believe some of the functionality of core was moved into Core_unix and this may have broken the example.

You need to add the core_unix.command_unix library to your dependencies.

2 Likes