27

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 ^_^

1
  • 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 4, 2017 at 12:26

2 Answers 2

56

Another option is rlwrap.

rlwrap sml
4
  • 6
    If you have macports, 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.
    – Unnamed
    Sep 12, 2013 at 19:46
  • I didn't know about rlwrap (or abusing socat as mentioned above) until I found this answer! Thanks!
    – user1898811
    Jul 9, 2014 at 21:51
  • 4
    Also works with homebrew: brew install rlwrap. You don't even need to change your bash_profile. Feb 16, 2017 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, 2020 at 1: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).

2
  • 9
    on my Linux, I use "rlwrap" to do the same thing: utopia.knoware.nl/~hlub/rlwrap
    – newacct
    Dec 16, 2009 at 6: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). Dec 16, 2009 at 6:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.