Zoom link
Any class zoom events will be in
this meeting.
Help Sessions
Monday afternoon (Dan Licata), 3:00pm-4:30pm+, Olin 14
Tuesday afternoon (Dan Licata), 4:20pm-5:30pm+, Exley 72
Sunday evening (Noa), 7:30pm-9:30pm, Exley 113 (except Exley 72 on Nov 17)
Monday evening (Noa, Tess, Jared), 7:30pm-9pm, Exley 72
Tuesday evening (Tess, Fernando), 7:30pm-9pm, Exley 113
Thursday evening (Fernando), 7:30-9pm, Exley 113
Labs
Lab (Dan, Joshua): Wednesday, 2:50pm-4:10pm, Olin 14
Handouts
Common recurrences
SML
To install smlnj:
Mac OS
These directions worked on Mac OS Catalina/Big Sur/Monterey/Ventura.
- Start the Terminal application by selecting it from your
Applications folder or by typing Terminal into Spotlight.
- If you don't have strong preferences about what unix shell you use, run
chsh -s /bin/bash
(then type your mac password and hit enter when prompted) to
switch your default shell to BASH from the new default of zsh.
If you do have strong preferences about using zsh, then you will need to add the
equivalent of the lines below setting your PATH and smlnj alias
to your zsh startup files.
- Close the terminal and then open a new one.
- In the terminal, run
xcode-select --install
Run the installer that pops up if one does; otherwise you
already have the command line tools installed.
- Install the Homebrew package
manager according to the directions on that page. I.e. copy
the script into the Terminal and run it.
At the end of the installation, it might (maybe only on Apple Silicon computers?) tell you two lines
to run in
the terminal, like
echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/$USER/.bash_profile
eval $(/opt/homebrew/bin/brew shellenv)
If it does, please do that. This sets some necessary environment variables, which
point homebrew to the right location on your system. The location of the brew executable might be
different than above on some systems (e.g. it might be /usr/local/bin/brew instead).
-
In the terminal, run
brew install rlwrap
.
-
In the terminal, run
brew install smlnj
.
- In the terminal, run
echo 'export PATH="/usr/local/smlnj/bin:${PATH}"' >> ~/.bash_profile
- In the terminal, run
echo 'alias smlnj="rlwrap sml"' >> ~/.bash_profile
- Close and restart the terminal and you should be able to
run smlnj to start SML.
Work arounds:
Windows
These directions were tested on Windows 10. If you have an earlier
version and this doesn't work, here are
some
old
directions that might work.
- Use
this installer.
- Install the VSCode editor and run SML in its terminal
according to the directions below.
- If you get an error that sml.bat is not found, first try restarting VSCode. If that doesn't fix it,
run PowerShell as an administrator and execute this command to add SMLNJ to
your path (assuming SML is installed in the default location):
[Environment]::SetEnvironmentVariable("PATH", $Env:PATH + ";C:\Program Files (x86)\SMLNJ\bin", [EnvironmentVariableTarget]::Machine)
And then restart VSCode.
Text Editor
On a Mac, we recommend VSCode or Sublime Text or GNU emacs
for editing SML source files. VSCode allows you to run a
terminal inside of the editor, so you can run smlnj in there. emacs
has a special mode for running SML code, but is less
new-user-friendly. For Sublime, you can only run SML code from the
separate Terminal application.
On Windows, we recommend VSCode.
VSCode
- Install VSCode
and start it.
- On the left-hand side, you should see an icon that looks like
three squares with one square sticking out. This is the place to
install extensions. Install the following two extensions:
- vscode-better-sml
- Tomorrow and Tomorrow Night Theme from Microsoft.
Click on this extension, and use the Set Color Theme button
at the top to select one of the themes if it doesn't already
prompt you to do so.
This should make colorful syntax highlighting work for SML
code.
- If you are on a Mac: Go to Settings in the bottom left corner, search for
Default Profile, and set Terminal › Integrated › Default Profile to bash.
This will make new terminals start bash by default.
- Create a folder for your COMP 212 work and select it
via Open Folder... (Windows) or Add folder to
Workspace... (Mac). You should put the .sml files you
download from the course web site into this folder.
- You can start a terminal in VSCode by using the Terminal / New
Terminal menu option.
- Type smlnj (Mac) or sml (Windows, if that
doesn't work try sml.bat) to
start SML.
Sublime Text
Sublime Text is
available here; get
version 4.
More specifically:
- Download the installer for your operating system. On Windows,
follow the instructions in the installer. On Mac, navigate to your
downloads and open the .dmg file. A pop-up
containing your local Applications folder and a Sublime Text
application file. Drag the Sublime Text file into the Applications folder.
- On Windows, you can open Sublime Text through the Start Menu.
On Mac, you can open Sublime Text in one of three ways:
- Finder: Open a new Finder window, navigate to your
Applications folder (it should be listed in the left-hand
column) and double-click on Sublime Text.
- Terminal: In terminal, enter “cd /Applications ; open
Sublime\ Text.app/“.
-
Launchpad: Open Launchpad and search for Sublime Text.
You may want to put a shortcut to Sublime Text on your desktop/in
your Dock.
- Install Package Control: Go to the Tools menu, click on Command
Pallet, and then type Install Package Control.
- To get syntax highlighting, install the "SML (Standard ML)"
package:
- Press on Tools > Command Palette in the menu bar and
search for “install package”, then press enter with Package
Control: Install Package.
- Search for “SML (Standard ML)” and press enter to install.
- To use SML highlighting, you may now navigate to View >
Syntax > SML.
Emacs
If you have Linux, you
almost certainly have emacs installed. For Mac and Windows get:
To install SML syntax highlighting:
- Make a software directory in your home directory
(to do this in the terminal, run mkdir ~/software/).
- Download sml-mode.tar and
unzip it in your software directory (to find it outside
the terminal, your software directory will be in software
in your home directory on a Mac or
in C:\cygwin\users\YOURNAME\software on Windows). This will
create a directory ~/software/sml-mode-3.3-custom.
- Open Emacs, type Control-x Control-f to open a
file, and then edit the line at the bottom of the screen to
Find file: ~/.emacs
and press enter. This is your emacs startup file.
-
Copy the the contents
of dotemacs-win.txt (Windows)
or dotemacs-mac.txt (Mac)
into this file. On Windows, you will need to edit the first line,
replacing YOURNAME with your Cygwin user name. NOTE: The
windows file is untested; let me know if you have problems.
- Save, close, and restart emacs.
- When you open emacs again and open a file.sml, it
will now color the syntax. Also, you can run SML inside emacs as
follows:
- Control-c Control-b: load the current emacs buffer into the SML
repl.
- Control-c Control-s: pop up a separate window with the
SML repl.
Some emacs resources:
- Start with this tutorial
on getting started with emacs
- To exit emacs, type Control-X, then Control-C. A prompt may
appear asking you about saving any changes you made; if this happens,
you will need to answer it before exiting.
- The emacs wiki is the
omnibus resource for emacs usage
- Wikipedia has an
article on the general history and culture of emacs, for the
curious.
Vim
If you used vim in COMP 211 and like it, we recommend this
sml mode.