Type judgements in Standard ML
The interactive system of Standard ML infers the type of any expression along
with evaluating it. In this first exercise, you can familiarise yourselves with
the interactive environment and the names of the built-in types of Standard ML by asking
the interactive system to infer the types from typical expressions.
Note: In order to get Standard ML to examine your input, you must terminate it with a semicolon.
Standard ML is installed at /tools/cs/smlnj/bin/sml on the CSEL machines.
- Determine the types of integral numbers, floating point numbers, and character strings.
- Determine the types of the literal values #"a", true, and false.
- Standard ML does not use -42 to represent negative 42. Determine the representation it uses instead.
- Standard ML uses the notion of tuples; the general form is (a, ..., c). Construct a few tuples and determine the types SML assigns to them.
- Determine the type of a tuple with no elements in it.
- There are several ways to describe functions in Standard ML. One of them is to write something like
fun f x:int = x * x;
which introduces a new function f.
Determine the type Standard ML gives to functions.
- Try to find a way to pass more than one argument to a function.
- What is the type of the special built-in value it?
- Like most functional languages, Standard ML provides lists, which behave like
singly-linked lists in memory. Lists are denoted as comma-separated values surrounded
by brackets, e.g. [1,2,3]. Determine whether it is possible to have
values of different types in the same list.
Copyright (C) 2003 Programming Languages group, University of Colorado
Christoph Reichenbach, reichenb (at) colorado.edu