ocaml - 在 utop 中使用随 opam 安装的软件包
问题描述
我用 opam 安装了 yojson:
opam install yojson
我想在 utop 中使用它,但我无法让它工作。我已经在 utop 中尝试了这些命令,但都没有工作(它抱怨找不到文件/包):
#use "Yojson";;
#use "yojson";;
#require "Yojson";;
#require "yojson";;
在 utop 中使用 opam 包时我应该注意什么其他配置?
解决方案
正确的调用是(包括#
字符):
#use "topfind";;
#require "yojson";;
第一个命令启用#require
指令(它不是标准指令,而是来自工具),如果它还没有,最好ocamlfind
将它添加到您的文件中。~/.ocamlinit
第二个指令实际上加载了yojson
库。您还可以使用该#list
指令列出所有可用的包,以及ocamlfind list
同一 puprose 的 shell 命令。
推荐阅读
- ruby - 无法让 azure Ubuntu VM 显示已安装的网站
- extjs - 如何从 EXT 网格中删除 headerCt 中的项目
- azure - 为什么创建 Azure AKS 群集时会自动创建 VM
- ruby-on-rails - 将 gem 添加到包中而不添加 Gemfile (rspec + fuubar)
- angular - 通过 *ngFor 列出用户后如何查找用户的个人数据
- logstash - 我怎样才能在logstash中获得特定的登录?
- fluent-nhibernate - 流利的 Nhibernate 忽略 CurrentSessionContext - 或无法带来当前会话
- django - 如何为第 3 方包覆盖模型中的 db_table?
- java - Java Collect 加入自定义函数
- python - jupyter notebook 的 iptables 规则