我应该如何组织我的OCaml项目? [英] How should I organise my OCaml project?

查看:98
本文介绍了我应该如何组织我的OCaml项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题是相当普遍的,我甚至不知道如何更好地问。






我不知道在 C 中没有太多经验,我只希望我能在OCaml中做类似Java中的事情。

例如,在 Java 中,我通常会创建一个项目(使用 Eclipse 或其他IDE),然后我有一个 src 文件夹和一个 bin 文件夹。所有编译的东西都转到 bin






因此,对于初学者,我怎么能做到像上面这样简单的事情?只是简单地拆分源文件和编译文件?




通常情况下,你们如何组织OCaml项目文件?






最后一个问题是,如果我使用 mli 模块?我注意到 ocaml-batteries-included 正在使用 mli 很多。

绿洲的一切。你应该看看几个随机的OCaml项目,看看它是如何工作的,以及你想要什么。例如,绿洲项目可能如下所示: https://github.com/avsm/ocaml-github 。你只需要看看_oasis文件(如果你曾经使用maven,可以把它看作是pom.xml文件)。运行 oasis setup 应该为你生成所有的构建文件。 ocaml setup.ml -all 后跟 ocaml setup.ml -install 会在您的系统上安装库。



至于使用mli的。对他们有一点争议。以下是邮件列表的讨论: http:// www。 mentby.com/Group/caml-list/why-should-i-use-mli-files.html



我个人的观点是他们是可选的除非你的模块是其他人使用的公共API的一部分。在这种情况下他们是强制性的。

I know this question is quite general and I even don't know how to better ask.


I don't have much experiences in C and I just wish I can do similar thing in OCaml as in Java.

For example, in Java, I normally create a project (using Eclipse or other IDE), then I have a src folder and a bin folder. All compiled stuff go to bin.


So for the starter, how could I do something as simple as above? just split the source files and compile files easily?


Normally, how do you guys organise OCaml project files?


The final question is that should I use mli or module? I noticed that ocaml-batteries-included is using mli a lot.

解决方案

There's plenty of differing opinion about this subject in the OCaml community and it really depends on how structure or flexibility do you want. Myself I use a makefile and ocamlbuild if I'm being lazy and oasis for everything else. You should check out a few random OCaml projects to see how it works and what you would like. For example an oasis project might look like so: https://github.com/avsm/ocaml-github. You only need to look at the _oasis file (think of it like pom.xml if you ever used maven). Running oasis setup should generate all of the build files for you. ocaml setup.ml -all followed by ocaml setup.ml -install would install the library on your system.

As for using mli's. There's a tiny bit of controversy regarding them. Here's a discussion from the mailing lists: http://www.mentby.com/Group/caml-list/why-should-i-use-mli-files.html

My own opinion is that they are optional unless your modules are part of a public API that others will use. In which case they are mandatory.

这篇关于我应该如何组织我的OCaml项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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