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: heads@cs51.io.

Setup instructions #

Head to http://url.cs51.io/lab8 and follow the Lab Procedures.

Lab puzzle #

Consider the following signatures X and Y and functor Funky.

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

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

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

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]