summaryrefslogtreecommitdiff
path: root/lec07
diff options
context:
space:
mode:
authorEdoardo La Greca2025-09-09 20:38:35 +0200
committerEdoardo La Greca2025-09-09 20:38:35 +0200
commit2c3d5c3504f38c57c0e4abc89da91fcec015151e (patch)
treeedf0fc00668f15d58ba6a5be01e477ffa95c03b2 /lec07
parentf46dafc461e4ee3fa1637051284f89b443f00a51 (diff)
add first exercise of lecture 7HEADmaster
Diffstat (limited to 'lec07')
-rw-r--r--lec07/JoinList.hs17
1 files changed, 17 insertions, 0 deletions
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
+