From 4047fa7672c3cc0b39885f223a05c2540954d197 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Thu, 25 Dec 2014 20:20:35 +0530
Subject: [PATCH] hw8: exercise 1 solutions

---
 hw8/Party.hs | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 hw8/Party.hs

diff --git a/hw8/Party.hs b/hw8/Party.hs
new file mode 100644
index 0000000..180e45a
--- /dev/null
+++ b/hw8/Party.hs
@@ -0,0 +1,20 @@
+{-# OPTIONS_GHC -Wall -fno-warn-orphans #-}
+module Party where
+
+import Data.Monoid
+import Employee
+
+-- exercise 1
+-- glCons - a naive way to add an employee to a guest list
+glCons :: Employee -> GuestList -> GuestList
+glCons e@(Emp {empFun = funval}) (GL els fun) = GL (e:els) (fun + funval)
+
+-- Monoid instance for GuestList
+instance Monoid GuestList where
+  mempty = GL [] 0
+  (GL el1 f1) `mappend` (GL el2 f2) = GL (el1 ++ el2) (f1 + f2)
+
+-- moreFun
+moreFun :: GuestList -> GuestList -> GuestList
+moreFun g1@(GL _ f1) g2@(GL _ f2) | f1 > f2 = g1
+                                  | otherwise = g2
-- 
2.45.2