structure PersonDB = struct

    exception PersonNotFound

    type 'x PersonRecord = {
	Name : string,
	Age : int,
	Address : string,
	SpecializedInfo: 'x
    }
	fun newPersonRecord(NameVal, AgeVal, AddressVal) =
	    {Name=NameVal, Age=AgeVal, Address=AddressVal, SpecializedInfo=nil}

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

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

    fun newProgrammer(NameVal, AgeVal, AddressVal, SalaryVal, StepVal) =
	{Name=NameVal, Age=AgeVal, Address=AddressVal, SpecializedInfo={
	    Salary=SalaryVal, Step=StepVal}}

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


    datatype 'p PersonDatabase = 
	EmptyDB |
	Body of 'p list
    (*with*)
	val newPersonDatabase = EmptyDB
	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