Domanda

I got a OCaml project for school and downloaded the template project they provide. Theres a file I need to edit called puzzle.ml. How do I use ocaml-top to edit/open the puzzle.ml file. I've been trying to troubleshoot this for hours and still no luck. Any tips or suggestions are appreciated. Thank you for your time!

Using Mavericks

È stato utile?

Soluzione

If simply running ocaml-top gives you an error that the command cannot be found, OPAM might not have set your PATH variable correctly, this can be fixed by adding the following to your shell config file:

export PATH=/Users/$USER/.opam/system/bin:$PATH #for bash
set PATH /Users/$USER/.opam/system/bin $PATH    #for fish

Altri suggerimenti

First of all, free book https://realworldocaml.org/ is your friend.

Second, ocamltop is not an editor, it is a running environment. You can use #use "yourfile.ml" to run your ocaml ml file.

Third, You can use whatever text editor to edit your source file.

Everybody else thinks you mean the standard OCaml top-level. However, ocaml-top is a gtk-based editor for editing and evaluating OCaml code: http://www.typerex.org/ocaml-top.html

I just installed it on my OS X Maverics system, which was really quite difficult. You say you have it installed already. If so, that's impressive as I really found it difficult :-)

Now that I have it installed, I can run it by saying:

$ ocaml-top

In the Terminal (the command line). It looks pretty good, and it does let me edit and execute OCaml code. I've only tried a few simple things.

However, ocaml-top uses X11 to display its windows. So, you also need to have X11 installed on your OS X system.

One way to work is to have an editor window next to the ocaml toplevel and just cut'n paste the lines you want to test.

Do you have the ocaml documentation? If not get it. In the chapter about the toplevel you will find the way to read in a file.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top