This program is exactly what we usually recommend for people who aren't using SML/NJ inside of an Emacs inferior window (which is far and away the most common usage mode for experienced SML/NJ programmers - all ten of us <grin>).<p>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.
I've been using rlwrap for years with Oracle's sqlplus command line client on Linux.<p>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.<p>For example, I'm a vi(m) user, so I put this in my .inputrc:<p><pre><code> set editing-mode vi
</code></pre>
That's just the tip of the iceberg.<p>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.
This is great, exactly what I needed for the new Coursera class about Programming Languages: <a href="https://class.coursera.org/proglang-2012-001/class/index" rel="nofollow">https://class.coursera.org/proglang-2012-001/class/index</a><p>(They start of with ML and a very simple REPL)
OS X users, I advise using<p><pre><code> brew install rlwrap
</code></pre>
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:<p><pre><code> 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.
</code></pre>
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:<p><pre><code> brew install rlwrap
</code></pre>
Perhaps this is just obvious to others. Would've saved me a few minutes to hear this, though.<p>[1]: <a href="http://mxcl.github.com/homebrew/" rel="nofollow">http://mxcl.github.com/homebrew/</a>
For the rlwrap gurus in the thread, is there a way to use rlwrap to better deal with multiline expressions in the repl?<p>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.
rlwrap seems cool at first blush, but you quickly realize that for anything nontrivial (e.g. context-aware autocomplete) you need to use readline directly
For people who like ruby but think irb sucks, there's pry (<a href="http://pryrepl.org/" rel="nofollow">http://pryrepl.org/</a>), but it's still missing some features.
ocaml has an awful default interpreter repl, so most people use it with emacs. Alternatively, my default rlwrap is this:<p>rlwrap -p"0;31" ocaml -init _init.ml<p>the -init allows me to preload, set directories aso.<p>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.