Standard ML repeat last command, left arrow?

2.5k views Asked by At

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?

3

There are 3 answers

0
William Denman On

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.

1
matzahboy On

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

Example:

ledit mosml
0
Sebastian Paaske Tørholm On

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.)