I’m using Standard ML of New Jersey, the latest release available at this time is the 110.74 version from Jan 20, 2012. This can be found here (where any newer versions released since should also be linked to): http://www.smlnj.org/dist/working/ Unfortunately, at least for me, it isn’t the easiest to find this page as google’s top hit sent me to the Sourceforge site for Standard ML of New Jersey (http://smlnj.sourceforge.net/) where the latest version available is the 110.60 version from back in December 2006. I used the Intel specific Mac OS installer package and this placed the files in the folder /usr/local/smlnj-110.74 Navigating to there and running sml from the bin (./bin/sml) provides access to a repl console. To exit the repl use ctrl+d. Next up for me was to get the sml-mode for emacs working. Sadly I couldn’t see any elisp packages available to do this for me (M-x list-packages), and besides doing these things manually provides more learnings I find. To get sml and emacs working together happily involved:
- getting the sml-mode elisp files and placing them in a new folder ‘~/.emacs.d/sml-mode’ – I like to keep all my emacs mode & other mod files together here
- I downloaded the sml-mode using the link here: ‘http://www.iro.umontreal.ca/~monnier/elisp/‘ – I plumped for the Download 5.0 July 2012. Running make for me resulted in a fair few warnings, but nothing too concerning I thought.
- editing my ~/.emacs file so that it can find that folder and will use the sml-mode when a .sml file is loaded into emacs, and so that the sml inferior mode is available to give me access to the sml repl from within emacs
;;; use sml-mode when file ends in .sml
(autoload ‘sml-mode “sml-mode” “Major mode for editing Standard ML code.” t)
(autoload ‘run-sml “sml-proc” “Inferior mode for running the compiler in a separate buffer.” t)
(setq auto-mode-alist
(append ‘((“\\.sml$” . sml-mode)) auto-mode-alist))
(setq sml-program-name “/usr/local/smlnj-110.74/./bin/sml”)
With this done if you load a file with the .sml extension or otherwise when you meta-X sml-mode then you get some syntax highlighting and help with indentation.
Also, if you meta-X run-sml and then hit enter (presuming that you’ve adjusted the sml-program-name from my path above if necessary) then you’ll get a new buffer opened with the sml repl running.
EDIT: I’ve created a small site with details of useful emacs commands, as well as detailing the SML Mode commands: http://neilrobbins.github.com/emacs_shortcuts/
To get this going I found this site on sml-mode very helpful and I recommend looking at it: http://www.smlnj.org/doc/Emacs/sml-mode.html#SML-Mode
This page also has some useful advice: http://www.cs.washington.edu/education/courses/cse341/07sp/help/sml-repl.html
Leave a Reply