6

I am learning standard ML using its interpreter. Sometimes I make typo and just want to repeat the previous command like in Linux shell. However, up arrow will end up with printing special characters on the screen. Sometimes I want to go back left to correct something, left arrow also results in printing special characters.

Does anybody know what is the correct way to do them?

jrouquie
  • 4,315
  • 4
  • 27
  • 43
Alfred Zhong
  • 6,773
  • 11
  • 47
  • 59
  • Looks like a duplicate of - http://stackoverflow.com/questions/1911861/how-to-fix-the-sml-nj-interactive-system-to-use-arrow-keys – Gangadhar Apr 07 '12 at 18:52
  • Excellent! How come I didn't find that at google... Thanks a lot for pointing out, that is awesome! – Alfred Zhong Apr 07 '12 at 19:14

3 Answers3

9

I use Moscow ML, but I figure the answer will apply to whichever version you use:

You can achieve what you want by using rlwrap.

I have the following alias set in my .zshrc, which handles it automatically:

alias mosml="rlwrap mosml"

(Substitute mosml for the name of your SML interpreter.)

Sebastian Paaske Tørholm
  • 49,493
  • 11
  • 100
  • 118
6

Consider using the program ledit. It allows you to use the arrow keys to visit previous commands.

Example:

ledit mosml
matzahboy
  • 3,004
  • 20
  • 25
0

If you are going to be doing any serious SML hacking I strongly suggest you use a development environment that allows you to interact with the SML top level environment.

I use Emacs with the SML mode. The beauty here is that in the top window you can code functions and save them to a file. You can then send them to the lower window that holds the Inferior-SML process for compilation. Also the Inferior-SML process has by default a command history.

William Denman
  • 3,046
  • 32
  • 34