Quantcast
Channel: OCaml - Topics tagged dune
Viewing all articles
Browse latest Browse all 534

Why does clarifying the namespace lead to unbound error but not adding the namespace doesnt

$
0
0
let file = "example.dat"
let message = "Hello!"

let () =
  (* Write message to file *)
  let oc = open_out file in
  (* create or truncate file, return channel *)
  Printf.fprintf oc "%s\n" message;
  (* write something *)
  close_out oc;

  (* flush and close the channel *)

  (* Read file and display the first line *)
  let ic = open_in file in
  try
    let line = input_line ic in
    (* read line, discard \n *)
    print_endline line;
    (* write the result to stdout *)
    flush stdout;
    (* write on the underlying device now *)
    close_in ic
    (* close the input channel *)
  with e ->
    (* some unexpected exception occurs *)
    close_in_noerr ic;
    (* emergency closing *)
    raise e

I have this snippet of code from official ocaml site, if I annotate the functions using
in_channel.open_out, in_channel.open_in then while building I get the error unbound module in_channel but if I just use open_out etc like above it compiles. I am confused about this seemingly unintuitive behavior can someone explain . I am using dune to build it. Thanks.

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 534

Trending Articles