sml

Getting started with sml

Remarks#

This section provides an overview of what sml is, and why a developer might want to use it.

It should also mention any large subjects within sml, and link out to the related topics. Since the Documentation for sml is new, you may need to create initial versions of those related topics.

Installation

There is a dozen implementations of Standard ML. MLton produces very optimized code, but has no REPL. SML/NJ is the most widely used, but has slightly difficult error messages for learning purposes. Moscow ML and Poly/ML are easy to get started with, but don’t support the .mlb package format. That isn’t essential for getting started, though.

Here are instructions for installing each of SML/NJ, Moscow ML and Poly/ML divided by operating system.

On Windows

SML/NJ:

Moscow ML:

  • Go to https://mosml.org/ and click “Download Win. Installer”. Run the installer.
  • You now have a REPL in e.g. C:\Program Files (x86)\mosml\bin\mosml.exe.

Using Homebrew On MacOS

SML/NJ:

  • Run brew install smlnj as your own user. Test REPL with smlnj.

Moscow ML:

  • Go to https://mosml.org/ and click “Download PKG File”. Run the installer.
  • Missing… Test REPL how? Is it in $PATH now?

On Ubuntu / Debian Linux

SML/NJ:

  • Run sudo apt-get install smlnj as the super user. Test REPL with smlnj.

Moscow ML:

  • (Ubuntu) Add the PPA as the super user. Test REPL with mosml.

    sudo add-apt-repository ppa:kflarsen/mosml
    sudo apt-get update
    sudo apt-get install mosml

Adding readline support

In order to be able to use the arrow keys to navigate lines that were previously typed into the REPL, most of the SML compilers can benefit from the program rlwrap. Using Homebrew on MacOS, install this by brew install rlwrap, and on Ubuntu / Debian Linux, install this by sudo apt-get install rlwrap. Then in the terminal, try the following:

alias mosml='rlwrap mosml -P full'
alias sml='rlwrap sml'
alias poly='rlwrap poly'

These aliases can be added to e.g. your ~/.bashrc so they work by default.

The arrows key should now work better.


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow