Gleb Alexeyev wrote:
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)
My
Gleb Alexeyev wrote:
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
I just realized that my sol
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 (CatL