【问题标题】:This expression has type int but an expression was expected of type [ `Deprecated_use_float_module ]此表达式的类型为 int,但预期的表达式类型为 [`Deprecated_use_float_module]
【发布时间】:2014-10-06 01:06:49
【问题描述】:

我正在使用 Jane Streets Core 库,并且正在尝试执行简单的 float_of_int 操作。我收到以下错误

This expression has type int but an expression was expected of type [ Deprecated_use_float_module ]

我该如何解决这个问题?例如,在utop 解释器内部:

utop # open Core.Std;;

utop # float_of_int 1;; Error: This expression has type int but an expression was expected of type [ Deprecated_use_float_module ]

谢谢!

编辑: 我还查看了 Float 模块 here 的内部,它似乎什么都没有。除非我只是不知道如何正确浏览文档,否则我不确定该怎么做。

【问题讨论】:

  • 文档站点上似乎存在错误。我通常只从 emacs 打开 mli 文件并在那里读取 cmets。如果您使用的是 opam,那么您可以在 .opam/<version>/lib/<library> 中找到 mli 文件,其中 代表 ocaml 版本,例如 4.01.0,而 是库名称,例如 core
  • 谢谢,您的回答解决了我的问题,但我对文档问题更感兴趣。从现在开始我会参考它:-)

标签: ocaml


【解决方案1】:

他们试图对你说,你应该使用Float.of_int 函数。 float_of_int 函数已被 Janestreet Core 库弃用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-31
    • 2022-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多