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


_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to