26

I'm having some trouble using SML/NJ interactive system, namely, that when I try to use my arrow keys (either left or right to make a correction in the expression I've typed, up to repeat the last expression), my Terminal prints codes. (e.g. ^[[A for up^[[D for left, etc.). While I can still use the system, it makes it very tedious.

I've looked around in Control.Compiler, is there something I'm missing? For whatever its worth, I'm using the Mac Terminal.

Thanks ^_^

pablo.meier
  • 2,339
  • 4
  • 21
  • 29
  • what a great language however the implementation of its interpretor is not user friendly at all. I cant find an equivalent of ipython for smlj which is unfortunate – Har Feb 04 '17 at 12:26

2 Answers2

56

Another option is rlwrap.

rlwrap sml
Telemachus
  • 19,459
  • 7
  • 57
  • 79
  • 6
    If you have [macports](http://www.macports.org/install.php), you can install `rlwrap` by running `sudo port install rlwrap`. Then add `alias sml='rlwrap /usr/local/smlnj/bin/sml'` to a new line on your `~/.bash_profile` file. – justspamjustin Sep 12 '13 at 19:46
  • I didn't know about rlwrap (or abusing socat as mentioned above) until I found this answer! Thanks! –  Jul 09 '14 at 21:51
  • 4
    Also works with homebrew: brew install rlwrap. You don't even need to change your bash_profile. – Priyank Desai Feb 16 '17 at 20:54
  • If you are using the `alias sml=path` suggested by @justspamjustin, you can find the `path` of your `sml` command by running `which sml` – jpenna May 30 '20 at 01:29
18

Try this. You can use socat to add readline support to many things:

socat READLINE EXEC:sml

I just realized you're on OS X. socat does seem to be available for OS X, although I have not tested it (this does work on Linux).

ZoogieZork
  • 11,215
  • 5
  • 45
  • 42
  • 9
    on my Linux, I use "rlwrap" to do the same thing: http://utopia.knoware.nl/~hlub/rlwrap/ – newacct Dec 16 '09 at 06:17
  • THANK YOU ^_^ Oh that feels so much better (though it took a fair bit of work getting socat up and working. The next box is a Linux). – pablo.meier Dec 16 '09 at 06:37