Course pages 2013–14
Foundations of Computer Science
Getting Access to ML
(updated Oct 2013)
There are many options for you to get access to a machine running Poly/ML (the variant of ML we use in practicals), including:
- MCS. MCS machines can be found throughout Cambridge, including the Intel Room in the Computer Laboratory and (very probably) your College. Poly/ML (our preferred implementation of ML) is installed on both Windows and Linux MCS machines. More details on the MCS in general can be found here.
- Remote MCS Linux. You can access an MCS linux machine from your own computer via SSH. More details are here.
- Your computer (Windows). Poly/ML is available to install on windows machines. The installer package is available here.
- Your computer (Linux) Most linux distributions include Poly/ML. For example, sudo apt-get install polyml works in Ubuntu. Failing that, you can always compile it from source (see the Poly/ML site).
- Your computer (Mac). The easiest way to install lots of open source software, including ML compilers, is via the package manager MacPorts. It is easy to use and installs software fairly quickly. Install it and then run sudo port install polyml.
- A Raspberry Pi. If you have access to a Raspberry Pi running the standard Raspbian linux distribution, you can get Poly/ML using sudo apt-get install polyml.
You may also find other implementations of ML are available. So long as they compile Standard ML (SML) you should find they work fine for this course. For example, Standard ML of New Jersey or Moscow ML. However, Poly/ML is he only one that receives regular updates and is generally supported...
- Setting the maximum printing depth. ML systems typically limit the output produce when very long lists and deep data structures are displayed on the screen. You can control how many lines are displayed using the in-built function PolyML.print_depth. e.g. PolyML.print_depth 10; would set it to show 10 lines (the remainder would appear simply as ....
- Running files in Poly/ML. Once you have written your ML text file (e.g. myfile.sml) you can run it in poly in one of two ways: you can run poly myfile.sml from the console or you can run use "mfile.sml" from within Poly/ML.
- Making the cursor keys work (Linux). To get the normal behavious of the console keys in Poly/ML, you need to run it through a program called ledit. This will mean you can press up/down to recall previous lines and left/right will move back and forth on the current line. You can install ledit using sudo apt-get install ledit (or equivalent). You then run ledit poly rather than just poly.
- Copy/paste in Windows. Windows is not really designed with
console access in mind and there can be some tricky things. Copy and
paste is a common problem, and might be solved thus:
- Open the command line.
- Click on the program icon in the top left of the window (alt + space).
- Select properties.
- Make sure that "QuickEdit Mode" is ticked.
- Press OK.
Once this is done, to paste code into the command line, perform one right click. Also you can highlight code by dragging a box over it. Once highlighted, you can then copy the selection by pressing enter.
- Editing ML on a Mac. Larry Paulson has written an ML Language Module for two Macintosh text editors: BBEdit and TextWrangler. It provides syntax colouring for keywords, strings and comments for filenames having the extension ML, sml or sig. To install for BBEdit, first quit the application. Then, copy the file StandardML.plist into the directory Library/Application Support/BBEdit/Language Modules/. The installation instructions for TextWrangler are analogous.