From 2c3d5c3504f38c57c0e4abc89da91fcec015151e Mon Sep 17 00:00:00 2001 From: Edoardo La Greca Date: Tue, 9 Sep 2025 20:38:35 +0200 Subject: add first exercise of lecture 7 --- lec07/JoinList.hs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lec07/JoinList.hs (limited to 'lec07/JoinList.hs') diff --git a/lec07/JoinList.hs b/lec07/JoinList.hs new file mode 100644 index 0000000..d04a0c6 --- /dev/null +++ b/lec07/JoinList.hs @@ -0,0 +1,17 @@ +module JoinList where + +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 m _ = m +tag Append m _ _ = m + +(+++) :: Monoid m => JoinList m a -> JoinList m a -> JoinList m a +(+++) jl1 jl2 = mappend jl1 jl2 + -- cgit v1.2.3