我一直在尝试针对用户键入无效目录的情况进行模式化:
# let dir = Unix.opendir "adfalf";;
Exception: Unix.Unix_error (Unix.ENOENT, "opendir", "adfalf").
我的功能如下:
let files_of_dir d =
try
let dir = Unix.opendir d in
...
with
Unix_error (uerr, ucommand, dir) -> raise Not_found
除了我不断收到编译错误:
Error: This variant pattern is expected to have type exn
The constructor Unix_error does not belong to type exn
我不明白我在模式匹配方面做错了什么。如果有人可以帮助我,将不胜感激!
其他一些注意事项:
我一直在终端上使用以下命令编译我的代码:
ocamlbuild filename.byte