Lab 8

Lab 8 Instructions #

Reminders #

  • While other students are coming into class, follow the setup instructions below. (But please wait until you’re instructed before beginning work on the lab.)

  • Raise your hand. Ask for help from the staff. That’s what we’re here for. Even if you think you’ve solved a problem, have a staff member look it over for further advice.

  • Remember, the goal is understanding, not getting the exercise to “work”.

  • Switch drivers early and often.

  • Do you have hints or tips about the course? Let us know:

Setup instructions #

Head to and follow the Lab Procedures.

Lab puzzle #

Consider the following signatures X and Y and functor Funky.

module type X =
    type t = int list
    val myval : t

module type Y =
    type u
    val f : u -> int

module Funky (M:X) : Y =
    type u = M.t
    let f (x:u):int = 
        match M.myval with
         | [] -> 0
         | _  -> 42

Suppose A is a module with signature X.

Is the following code well-typed?

module B:Y = Funky(A)
let i = B.f [7;42]