[Haskell-cafe] Re: Interesting problem from Bird (4.2.13)

Gleb Alexeyev gleb.alexeev at gmail.com
Wed Mar 4 11:56:01 EST 2009

Here's my attempt though it's not really different from using built-in 

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

More information about the Haskell-Cafe mailing list