出力順がおかしい気がする

勘違いでした。

let _ =
  let lexbuf = Lexing.from_channel stdin in
  let d = Parser.p Lexer.token lexbuf in
  let mods = Abs.all_modules d in
    begin
      Printf.printf "Dependency:\n";
      List.iter Dep.print d;
      Printf.printf "All Modules:\n";
      List.iter (fun p -> Printf.printf "%s\n" (Path.to_string p)) mods;
    end

のようなコードを実行すると

Dependency:
(* List.iter Dep.print d; の結果 *)
All Modules:
(* List.iter (fun p -> Printf.printf "%s\n" (Path.to_string p)) mods; の結果 *)

となって欲しいのですが、

Dependency:
All Modules:
(* List.iter (fun p -> Printf.printf "%s\n" (Path.to_string p)) mods; の結果 *)
(* List.iter Dep.print d; の結果 *)

のような出力になるのです。なんで?

いつからOCamlは遅延評価する言語になったのでしょうか。

とりあえず入力が十分に長いと、ちゃんとした順番で出力されるので、実害はないのですが。

※わかった

Dep.printのなかで、他のモジュールで使っているPrintf.printfと間違えて、Format.printfを使っていたのが原因だと思う。