(They start of with ML and a very simple REPL)
Many thanks, regardless! I upvoted your thread in the course general discussion, and I hope any other course takers on HN do to. It would be a shame if the non-hn course takers missed out on the thread (https://class.coursera.org/proglang-2012-001/forum/thread?th...).
I personally apologize for my laziness. Two or three different times I've started in on making something similar to the haskeline package in GHC to provide readline-style support to make life easier for students, but have never quite finished it up. Unfortunately, "just linking" readline/libedit isn't a very friendly solution given the way that the interpreter is currently architected, as it's written on top of the ML basis library primitives for reading/writing individual characters from the input stream.
[1]: https://class.coursera.org/proglang-2012-001/class/index
Because it uses readline, it can benefit from settings in ~/.inputrc, along with all of your other readline-based applications for a more uniform experience.
For example, I'm a vi(m) user, so I put this in my .inputrc:
set editing-mode vi
That's just the tip of the iceberg.These days, I tend to use the dbext vim extension for Oracle queries, allowing me to develop and save them in one file per project. But when I need to fire off something quick on the command line, it's nice to have rlwrap available.
brew install rlwrap
instead of downloading the tarball in the link. You may feel tempted to download a tarball and compile readline. But I experienced the problem mentioned in rlwrap-0.37/BUGS: 49-On recent OS X sytems, libreadline is not the real thing, but a
50-non-GNU replacement. If the linker complains about missing
51:symbols, install GNU readline and try again.
This may then lead you to attempt compiling and installing GNU readline, which will ultimately lead you to try to solve more problems you're having in compiling readline. You might find this fun. But if you just want to get things over with, there is an easier way. Homebrew[1] to the rescue: brew install rlwrap
Perhaps this is just obvious to others. Would've saved me a few minutes to hear this, though.> Simply install rlwrap via your operating system’s package manager (or manually)
But I'll add an update that mentions the bug on OSX. Thanks for the feedback.
For example, when using a clojure repl and entering a multiline expression, I might err on one line and want to go back and correct that line before evaluating the expression. Unfortunately, the only option I have right now is to terminate that expression by entering in a bunch of closing parens and then trying to enter in the entire multiline expression again. It'd be great if multiline expressions could be modifiable and if you could up arrow to load a previous multiline expression.
If you're to the point where you are editing lots of multiline expressions you may want to consider using an editor that has a function that will send the contents of a buffer or the current expression to a running interpreter. Emacs is an obvious choice for this, but there are lots of plugins to other editors/IDEs that do the same.
Such a simple idea, yet so effective.
rlwrap -p"0;31" ocaml -init _init.ml
the -init allows me to preload, set directories aso.
As a remark on the side. A lot of people complain about a lot of things without even bothering to improve the quality of their working environment.