Ocaml and Opam: unbound module Core

蓝咒 提交于 2019-12-18 10:15:27

问题


I'm trying to get an ocaml environment set up, and I've followed the instructions from appendix A of the Real World Ocaml beta. I set up opam, and installed a version of ocaml with the command

$ opam switch 4.01.0dev+trunk

which passed fine. I then did an

$ eval `opam config env`

to pull in the changes. I'm running the correct top level, as

$ which ocaml

outputs

/home/bryan/.opam/4.01.0dev+trunk/bin/ocaml

I installed the Core package from Jane street, with the command

$ opam install core

Both ocamlfind and opam search show that the package was installed correctly. However when I try to open it either from the repl or in a file, I get the error 'unbound module Core'. e.g.

$ ocaml
# open Core;;
Error: Unbound module Core

Is there something I'm missing here? Why can't ocaml find my installed module? Thanks in advance.


回答1:


So I jumped the gun a bit. I forgot to add some items to my ~/.ocamlinit file. Specifically I forgot to add

#use "topfind"
#camlp4o
#thread
#require "core.top"
#require "core.syntax"

as mentioned in Chapter 1. D'oh!




回答2:


Please follow the steps in the Real World OCaml Wiki - Installation Instructions.

Under Setting up and using utop, the instructions state that you should add:

#use "topfind";;
#thread;;
#camlp4o;;
#require "core.top";;
#require "core.syntax";;

to your ~/.ocamlinit file.



来源:https://stackoverflow.com/questions/17645634/ocaml-and-opam-unbound-module-core

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!