sml_tk patches

sml_tk is a package for Standard ML that interfaces with Tcl/Tk allowing Tk GUIs to be created in SML. Documentation and source code are available from the official web site.

The software does not seem to have been maintained since 2001. However, after some minor patches, it is still a viable and useful GUI package for SML.

Win32: it is necessary to use the cygwin version of SML/NJ on Windows because the standard version does not include a POSIX module. I have not tried using Poly/ML or compiling the tcl/tk-interface into sml_tk.

Some updated patches and instructions are provided by Kenji Nozawa.

Patches

for SML/NJ working versions prior to 110.61

There is a bug in the POSIX.TTY routines of SML/NJ 110.59 and 110.60 that causes a segmentation fault when running sml_tk. It is fixed by either of these patches: 110.59, 110.60. They are already included in the FreeBSD lang/sml-nj-devel port. These patches were incorporated into version 110.61.

The following expressions will cause a segmentation fault on an unpatched version of SML/NJ 110.58/59/60:

val {cc, ...} = Posix.TTY.fieldsOf (Posix.TTY.getattr Posix.FileSys.stdin);
val cc' = Posix.TTY.V.update (cc, []);

The config/install.sh script only rebuilds the run-time library if it cannot be found in bin/.run/run.$ARCH-$OPSYS. This file should thus be deleted after applying the patch, and before rebuilding with config/install.sh (e.g. rm bin/.run/run.x86-cygwin).

Reproducing and then fixing the bug on a Unix system:

  1. Download the 110.60 version of config.tgz
  2. gunzip -c config.tgz | tar xf -
  3. ./config/install.sh
  4. ./bin/sml
  5. Evaluating the two expressions given above gives: ./bin/sml: Fatal error -- unexpected fault, signal = 11, code = 0xb771e746
  6. patch -p0 < smlnj-110.60-ttyfix.patch
  7. rm bin/.run/run.x86-linux
  8. ./config/install.sh
  9. ./bin/sml
  10. Repeating step 5 should no longer give an error.

for sml_tk itself

Some minor adjustments to the sml_tk source are required for it to compile on SML/NJ 110.59. This patch contains the necessary adjustments plus some other minor fixes and extensions.

Walk through to demo

  1. Install a patched version of SML/NJ 110.59 or 110.60.
  2. Download and untar the sml_tk sources
  3. Download and untar the patches
  4. patch -p0 < sml_tk-patches/sml_tk-3.0.20080113.patch
  5. Optional: patch -p0 < sml_tk-patches/config-showColor.patch
  6. Optional: patch -p0 < sml_tk-patches/litem.patch
  7. Optional: patch -p0 < sml_tk-patches/widget_tree.sml-scrollbar.patch
  8. Change into the sml_tk directory.
  9. Edit the Makefile setting values for:
    1. SMLTK_LIB: Path to the sml_tk/lib subdirectory, e.g.: ${PWD}/lib
    2. SMLTK_TCL: Path to the wish executable, e.g.: /usr/local/bin/wish8.4
    3. SMLTK_BINARY: Path to create an sml_tk heap, e.g.: ./sml-tk
  10. Run make
  11. Run the newly created heap, e.g. cd src; ./sml-tk
  12. Try one of the examples: BigEx.go (); (which should start a small demo in a new window).