diff options
Diffstat (limited to 'lec07')
-rw-r--r-- | lec07/JoinList.hs | 17 |
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 + |