Question

I'm new to Standard ML and I'm trying to get my head around the SML/NJ runtime environment. I want to adapt it to my needs. Specifically, I want to:

  • Use IntInf by default
  • Prevent it from truncating strings and IntInf to 70 characters.

Here's what I've found in my 8+ hours reading documentation and experimenting.

I can overload IntInf on top of int with the command

open IntInf;

I can control how many characters in a string are displayed with the variable Control.Print.stringDepth. For example, this will let it display 1000 characters before truncating:

Control.Print.stringDepth := 1000;

How do I do the same for IntInf values? Can I set the depth to be infinite (that is, no truncation at all)?

Is opening IntInf the best way to overload int with IntInf?

Finally, how to I make this all load automatically at runtime so that when I invoke "sml" it's in my default environment?


Edit: I've since found out there is an option called Control.Print.intinfDepth that can be set to a large number (say, 999999). I don't know how to make it infinite, though.

My other questions still remain unanswered.


Edit: I ran across this set of SML/NJ customizations for a class at Kansas State. To display my own banner message and avoid displaying "val it = true : bool" I need to test the return value of SMLofNJ.exportML. If it's true, the heap image was just restored (ie, started up) and I can display a message. If it's false, the heap image was just saved.

Was it helpful?

Solution

How do I make this all load automatically at runtime so that when I invoke "sml" it's in my default environment?

You need to create a heap image to be run by the sml script, which you can then symbolically link to. To avoid complications of bootstrapping, I usually give my heap image a different name; for example; sml-nw for SML/NJ with support for noweb.

The basic primitive you need to create a heap image is SMLofNJ.exportML. Here's how you use it:

  1. Set up everything the way you want it by, e.g., open IntInf and setting all your Control.Print variables. (You could try setting Control.Printthings tovalOf Int.maxInt`, which is the closest thing to infinity.)

  2. Create a new heap image by SMLofNJ.exportML "mysml". When you start your customized version, you'll begin right after the call to exportML. Read the documentation. Play around; there are a lot of ways to use this primitive.

  3. Copy the heap image (maybe mysml.x86-linux) to the installation directory for heap images (on my installation, /usr/lib/smlnj/bin/.heap, but you can follow clues in the sml script to be sure)

  4. Create a script mysml that is a symbolic link to the sml script.

In the old days this was enough, but I haven't been using SML/NJ for several years now. I also found a somewhat outdated example on the web.

OTHER TIPS

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