type Employee = String type Spouse = String type Salary = Integer type Manager = String type Record = (Employee, Spouse, Salary, Manager) type DB = [Record] overpaid :: DB -> [String] overpaid [] = [] overpaid(x:xs) | ((getManager_R x) /= "Root" ) && ((getSalary_R x) > managerSalary ) = (getEmployee_R x):(overpaid xs) | otherwise = []:(overpaid xs) where managerSalary = getSalary_R (getManager_E (getManager_R x) xs) --grossly_overpaid :: DB -> [String] --spouse_manager :: DB -> [String] --spouse_manager_super :: DB -> [String] --super_manager :: DB -> [String] --nepotism :: DB -> [String] --rich :: DB -> [String] --sorted_salaries :: DB -> [String] --sorted_rank :: DB -> [String] --sorted_worth :: DB -> [String] --normalize :: DB -> [String] -- Functions to get all the matching elements from type DB allEmployee :: DB -> [String] allEmployee [] = [] allEmployee (x:xs) = (getEmployee_R x):(allEmployee xs) allSpouse :: DB -> [String] allSpouse [] = [] allSpouse (x:xs) = (getSpouse_R x):(allSpouse xs) allSalary :: DB -> [Integer] allSalary [] = [] allSalary (x:xs) = (getSalary_R x):(allSalary xs) allManager :: DB -> [String] allManager [] = [] allManager (x:xs) = (getManager_R x):(allManager xs) -- Functions to get the matching element from type Record getEmployee_R :: Record -> String getEmployee_R (s,_,_,_) = s getSpouse_R :: Record -> String getSpouse_R (_,s,_,_) = s getSalary_R :: Record -> Integer getSalary_R (_,_,i,_) = i getManager_R :: Record -> String getManager_R (_,_,_,s) = s -- Functions to get matching element from type String, DB getManager_E :: String -> DB -> Record getManager [] = [] getManager_E s (x:xs) | s == getManager_R x = x | otherwise = getManager_E s xs database0 = [("Lana Turner", "Buster Keaton", 80000, "Virginia Dare"), ("Ted Hughes", "Edna Millay", 70000, "Virginia Dare"), ("Virginia Dare", "Laurence Sterne", 100000, "Edna Millay"), ("Buster Keaton", "Lana Turner", 80000, "Ingrid Joyce"), ("James Joyce", "Ingrid Joyce", 60000, "Root"), ("Vanessa Redgrave", "Michael Redgrave", 110000, "James Joyce"), ("Michael Redgrave", "Vanessa Redgrave", 40000, "Vanessa Redgrave"), ("Edna Millay", "Ted Hughes", 70000, "Root"), ("Laurence Sterne", "Virginia Dare", 60000, "James Joyce"), ("Ingrid Joyce", "James Joyce", 60000, "Virginia Dare")] database1 = [] database2 = [("Carol", "Eric", 200000, "Bob"), ("Fran", "Dan", 200000, "Eric"), ("Bob", "Alex", 100000, "Alex"), ("Dan", "Fran", 150000, "Carol"), ("Alex", "Bob", 100000, "Root"), ("Eric", "Carol", 300000, "Dan")] database3 = [("Carol", "Eric", 200000, "Root"), ("Fran", "Dan", 200000, "Root"), ("Bob", "Alex", 100000, "Alex"), ("Dan", "Fran", 150000, "Root"), ("Alex", "Bob", 100000, "Root"), ("Eric", "Carol", 300000, "Root")] -- database4 = [("Carol", "Eric", 200000, "Root")]