import Data.Monoid
import Employee
import Data.Tree
+import qualified Data.List as L
-- exercise 1
-- glCons - a naive way to add an employee to a guest list
maxFunPair :: Tree Employee -> (GuestList, GuestList)
maxFunPair (Node e es) = nextLevel e $ map maxFunPair es
+-- exercise 5
+-- main
+
+sortedGL :: GuestList -> (Integer, [String])
+sortedGL (GL empls funval) = (funval, L.sort $ map empName empls)
+
+getEmployeeList :: String -> String
+getEmployeeList empls = let (f, ls) = sortedGL (maxFun (read empls))
+ in
+ unlines $ show f : ls
+
+main :: IO ()
+main = do
+ empls <- readFile "company.txt"
+ putStrLn $ getEmployeeList empls