0

我一直在试图为模式的情况下,用户类型无效目录:尝试模式匹配Unix_error(Ocaml)时出错?

# 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 

回答

1

你需要说Unix.Unix_error,不只是Unix_error。请注意,这是您的示例会话中显示的内容。

+0

谢谢!!!这让我很头疼 – 14wml