Posts Tagged ‘sml’

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): 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 ( 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:

  1. 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
    1. I downloaded the sml-mode using the link here: ‘‘ – 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.
  2. 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:

To get this going I found this site on sml-mode very helpful and I recommend looking at it:

This page also has some useful advice:



Read Full Post »

%d bloggers like this: