From 112ab0cf035304d521aaf51dea1c021f7e2d2c46 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Wed, 24 Dec 2014 19:54:10 +0530
Subject: [PATCH] hw7: exercise 1

---
 hw7/JoinList.hs | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 hw7/JoinList.hs

diff --git a/hw7/JoinList.hs b/hw7/JoinList.hs
new file mode 100644
index 0000000..4edc744
--- /dev/null
+++ b/hw7/JoinList.hs
@@ -0,0 +1,22 @@
+{-# OPTIONS_GHC -Wall #-}
+module JoinList where
+
+import Data.Monoid
+
+
+data JoinList m a = Empty
+                  | Single m a
+                  | Append m (JoinList m a) (JoinList m a)
+                    deriving (Eq, Show)
+
+-- exercise 1
+tag :: Monoid m => JoinList m a -> m
+tag (Empty) = mempty
+tag (Single t _) = t
+tag (Append t _ _) = t
+
+(+++) :: Monoid m => JoinList m a -> JoinList m a -> JoinList m a
+Empty +++ x = x
+x +++ Empty = x
+alst1 +++ alst2 = Append ((tag alst1) `mappend` (tag alst2)) alst1 alst2
+
-- 
2.45.2