如何解决没有标签就不能应用 Ocaml 参数
我正在我的 linux 机器上编译一个 ocaml 项目我收到这个错误
The function applied to this argument has type
?eq:('week4 -> 'week4 -> bool ) -> bool
This argument cannot be applied without label.
这是代码
let rec reduceandor (ee: e_expression) : e_expression =
match ee with
| EE_loc_function_EEL (ll,f,eel) ->
fail "EE_loc_function_EEL,reduceandor,transform2.ml"
| EE_function_EEL (f,eel) when (f = Function.AND) || (f = Function.OR) ->
(* https://stackoverflow.com/a/30634912/702977 *)
let uniq_cons x xs = if List.mem (fun ee0 ee1 -> ee0 = ee1) x xs then xs else x :: xs in
let remove_from_right xs = List.fold_right uniq_cons xs [] in
let eel_wo_duplicates = remove_from_right eel in
if List.length eel_wo_duplicates = 1
then List.nth eel_wo_duplicates 0
else EE_function_EEL (f,eel_wo_duplicates)
| _ ->
ee
错误在这一行
let uniq_cons x xs = if List.mem (fun ee0 ee1 -> ee0 = ee1) x xs then xs else x :: xs
问题是当我在 Mac 机器上编译项目时一切正常。
两台机器上的 ocaml 版本是:4.07.1
Opam 版本:2.0.2
解决方法
我假设您使用的是替代标准库,该库隐藏了 List.mem
的原始实现。如错误所示,您需要将等式谓词与标签相关联,如下所示:
List.mem ~eq:(fun ee0 ee1 -> ee0 = ee1) x xs
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。