
4 Mar
2009
4 Mar
'09
11:56 a.m.
Here's my attempt though it's not really different from using built-in lists: viewCL CatNil = Nothing viewCL (Wrap a) = Just (a, CatNil) viewCL (Cat a b) = case viewCL a of Nothing -> viewCL b Just (x, xs) -> Just (x, Cat xs b) instance Eq a => Eq (CatList a) where a == b = case (viewCL a, viewCL b) of (Just (x, xs), Just (y, ys)) -> x==y && xs == ys (Nothing, Nothing) -> True _ -> False