structure PersonDB = struct

    exception PersonNotFound

    type 'x PersonRecord = {
	Name : string,
	Age : int,
	Address : string,
	SpecializedInfo: 'x
    }

    (*
     * Note that the remaining record type defs are strictly documentary.
     *)
    type StaffEmployee = {
	HourlyWage: int,
	EmploymentStatus : int
    } PersonRecord

    type Programmer = {
	Salary: int,
	Step: int
    } PersonRecord

    type Manager = {
	Salary: int,
	Step: int,
	Supervisees: int
    } PersonRecord


    datatype 'p Database = 
	EmptyDB |
	Body of 'p list
    with
	fun AddPerson(EmptyDB, p) = Body([p]) |
	    AddPerson(Body(b), p) = Body(b @ [p])
	fun FindPerson(EmptyDB, p) = raise PersonNotFound |
	    FindPerson(Body((p as {Name=n,  ...}) :: ps), name) =
		if name = n then
		    p:'p PersonRecord
		else
		    FindPerson(Body(ps), name)
    end
end

open PersonDB

val JoeRec = {Name="Joe Hack", Age=22, Address="1415 Mockingbird Lane",
		 SpecializedInfo={Salary=60000, Step=2}}