diff --git a/src/GoodList.hs b/src/GoodList.hs index 47f66c6..37b50d9 100644 --- a/src/GoodList.hs +++ b/src/GoodList.hs @@ -55,9 +55,7 @@ snoc (Multiple a b c) = Multiple a (b `snoc` c) append :: GoodList a -> GoodList a -> GoodList a append Empty ys = ys append (Singleton x) ys = cons x ys -append xs Empty = xs -append (Multiple a b c) (Singleton y) = Multiple a (snoc b c) y -append (Multiple a b c) (Multiple d e f) = Multiple a (snoc b c `append` cons d e) f +append (Multiple a b c) ys = cons a . append b $ cons c ys join :: GoodList (GoodList a) -> GoodList a join Empty = Empty diff --git a/test/Main.hs b/test/Main.hs index ed63923..7943648 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -3,6 +3,10 @@ import GoodList abc :: GoodList Char abc = cons 'a' $ cons 'b' $ cons 'c' Empty +def :: GoodList Char +def = cons 'd' $ cons 'e' $ cons 'f' Empty main :: IO () -main = print abc +main = print abc >> + print def >> + print (abc `append` def)