Search code examples
unit-testingsmlml

Installing SML/NJ library


I need to install QCheck/SML unit test library for ML.

I could git clone the code, and create the .cm file, but I'm not sure how to copy the generated file into where. The document simply says (http://contrapunctus.net/league/haques/qcheck/qcheck_2.html):

2.1 SML/NJ

For Standard ML of New Jersey, the CM library specification ‘qcheck.cm’ should be all you need. The default target of make -f Makefile.nj will ask CM to build and stabilize this library. This creates a file ‘.cm/x86-unix/qcheck.cm’ (alter the arch/os tag as needed) which may be copied into the standard CM library path and added to the ‘pathconfig’.

I used brew install smlnj for the ML installation in Mac, so I have SMLNJ_HOME at /usr/local/Cellar/smlnj/100.78/SMLNJ_HOME.

enter image description here

What is the CM path library in this? In general, how to install a library into SML/NJ?

Edit

From Matt's answer, this is how I made it work.

Setup

  1. Copy the whole qcheck directory into /usr/local/Cellar/smlnj/110.78/SMLNJ_HOME/lib.
  2. Make ~/.smlnj-pathconfig file.
  3. Add qcheck.cm /usr/local/Cellar/smlnj/110.78/SMLNJ_HOME/lib/qcheck in the file.

Usage (in REPL)

  1. CM.make "$/qcheck.cm";
  2. open QCheck;

Things to consider.

  1. I couldn't use the stabilized libraries (qcheck/.cm/x86-unix/qcheck.cm). So, I had to copy the whole directory.
  2. For user's library, I think the install location can be anywhere, as the ~/.smlnj-pathconfig can point to the directory.
  3. For importing a structure in the same directory, use "FILENAME"; is needed instead of CM.make.

Solution

  • The CM library path is located in SMLNJ_HOME/lib. You can place the .cm file here. The instructions say to modify the pathconfig file, however, I would suggest creating a .smlnj-pathconfig file in your home directory instead. You are going to want to then paste the following line into that file:

    qcheck.cm <path to directory containing qcheck.cm file>
    

    You can then reference this in one of your .cm files using the anchor name: $/qcheck.cm. I've not used stabilized libraries before, and the generated .cm file is giving me a bunch of errors. If you instead use the qcheck.cm file from the root directory of the qcheck repo, it seems to work for me. Perhaps someone else can comment on why I am getting these errors.