Question

I found that polyml is the implementation of ML that can be easily installed on Ubuntu (named polyml in repository and can be executed with poly). I am following the A Gentle Introduction to ML by Andrew Cumming. After few minutes of experiment with polyml interpreter I found that it does not supports readline (pressing arrow up key produces a ^[[A).

This doesn't seems to be normal for an interpreter. This should only happen if I have no readline installed, but my Python interpreter doesn't behaves so.

Was it helpful?

Solution

The simplest way to add readline support to a terminal program that does not natively support it, is to call the program using rlwrap. You can install the package of the same name through several package managers. Pressing in the examples below:

$ poly
Poly/ML 5.7.1 Release
- ^[[A

You can run it like this:

$ rlwrap poly
Poly/ML 5.7.1 Release
- stuff I typed from last session;

Or you can add an alias in your ~/.bashrc or similar:

alias poly='rlwrap poly'

OTHER TIPS

The following two QA answers your question, though for sml/nj. It should not be any different for polyml

If you are interested in Standard ML and Poly/ML you should also take a look at Isabelle/ML. Isabelle is mainly targeted as theorem proving environment, but can be used as ML system as well -- if you don't mind 300 MB download and 600-800 MB disk footprint to get a full IDE.

ML snippets can be compiled and evaluated on the spot, by embedding them into Isabelle theory source like this:

theory Scratch
imports Main
begin

ML {*
  fun f x = x + 1
*}

end

In Isabelle/jEdit this gives tooltips about inferrred types etc. -- a bit more than just readline but useful for learning SML.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top