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

2009-03-06 Thread wren ng thornton
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

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

2009-03-06 Thread Gleb Alexeyev
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

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

2009-03-04 Thread Gleb Alexeyev
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