模块和包装Ocaml之间的区别 [英] Difference between module and package Ocaml

查看:88
本文介绍了模块和包装Ocaml之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基本上是在尝试遵循本文中的stackoverflow答案:

I'm basically trying to follow this stackoverflow answer located in this post:

OCaml中HttpRequest的最佳模块是什么

,我遇到了问题.当我尝试仅使用

and I'm running in to problems. When I am trying to run a single file with just

open Lwt ;; 

我得到了一个错误,并说它是一个未绑定的模块.我已经执行了以下opam指令:

I am getting and error saying it is an unbound module. I have run the following opam instruction:

opam install lwt

,它确实安装了正确的 package .

and it did install the correct package.

因此,我认为问题在于模块和软件包之间的差异,我对此并不了解.我一直在寻找这个问题作为可能的答案,但是我不确定这是否是我所需要的.

So I think the problem is the difference between a module and a package, which I don't really understand. I was looking at this question as a possible answer, but I wasn't sure if it was what I needed.

OCaml中的未绑定模块

感谢输入专家,我是Ocaml的新手,我正在尝试学习构建东西的来龙去脉.

Thanks for the input guys, I'm new to Ocaml and I'm trying to learn the ins and outs of building something.

推荐答案

要使用程序包",必须明确告知编译器有关此程序包的信息. OCaml中的未绑定模块通常意味着以下两种情况之一:您对模块名称进行了打错,或者未能设置正确的模块搜索路径.您使用什么编译器选项?

To use a "package", you must tell the compiler about it explicitly. Unbound module in OCaml usually means one of two things: your made a typo of the module name, or you failed to set a proper module search path. What compiler options do you use?

如果您使用ocamlfind,则编译应如下所示:

If you use ocamlfind, the compilation should look like:

ocamlfind ocamlc -package lwt -c mymodule.ml

ocamlfind ocamlc -package lwt -c mymodule.ml

这指示编译器除了默认模块外,还尝试在lwt软件包安装目录中查找模块.

this instructs the compiler to try to find modules in lwt package installation directory, in addition to the default ones.

如果您不使用ocamlfind....好吧,请使用ocamlfind.

if you do not use ocamlfind.... well, use ocamlfind.

这篇关于模块和包装Ocaml之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆