Exercise #1

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.
  1. Determine the types of integral numbers, floating point numbers, and character strings.
  2. Determine the types of the literal values #"a", true, and false.
  3. Standard ML does not use -42 to represent negative 42. Determine the representation it uses instead.
  4. 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.
  5. Determine the type of a tuple with no elements in it.
  6. 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.
  7. Try to find a way to pass more than one argument to a function.
  8. What is the type of the special built-in value it?
  9. 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.
Standard ML is installed at /tools/cs/smlnj/bin/sml on the CSEL machines.
Copyright (C) 2003 Programming Languages group, University of Colorado
Christoph Reichenbach, reichenb (at) colorado.edu