Laszlo Nemeth wrote:
> 
> Kevin Atkinson wrote:
> 
> > cons   :: a -> c a -> c a
> > empty  :: c
> > foldr  :: (a -> b -> b) -> b -> c a -> b
> 
> I am not an expert. I have a minor problem with this, the type of
> empty: if c stands for a type constructor then empty should have type
> (c a). 

Yes (c a) typo.

> Moreover, I don't understand why you use 'c' for lists (if you
> are hoping for polytypism, -- abstraction over type constructors --
> that is being able to zip trees etc, then this is not going to work)

Yes I mean ANY container that supports those 3 functions

> 
> Now, if by zipping you mean the operation defined in the Prelude
> (slightly differently) as:
> 
> zip :: [a] -> [b] -> [(a, b)]
> zip (x:xs) (y:ys) = (x,y):zip xs ys
> zip _      _      = []
> 
> then (you still need pairing and case)
> 
> foldr (\ a g ys -> case ys of
>                     []     -> empty
>                     (b:bs) -> (a,b) `cons` g bs)
>       (\ _ -> [])

But only for lists.  As you are patern matching on ":".

-- 
Kevin Atkinson
[EMAIL PROTECTED]
http://metalab.unc.edu/kevina/


Reply via email to