zipWith, zipWith3, zipWith4.... looks gawky, IMHO

Coeus@gmx.de Coeus@gmx.de
Sun, 18 Aug 2002 18:32:27 +0200 (MEST)


Hi all.
I'm new to this mailing list. (and still a relative newbie in Haskell -
learning GraphicsLib)
Because the Wish List did not work (maybe it is my browsers fault), I now
write it to this list.

I found the zipWithN functions in the standard libs, but imho it would be
much more comfortable to use operators like in this example:


zipWith6 :: (a->b->c->d->e->f -> g) -> ([a]->[b]->[c]->[d]->[e]->[f] -> [g])
zipWith6 f as bs cs ds es fs =  f :< as >< bs >< cs >< ds >< es >< fs

infixl  123whatever  (:<), (><)
-- lower priority than (++)

(:<) :: (a->b) -> [a] -> [b]
(:<) = map

(><) :: [(a->b)] -> [a] -> [b]
(><) = zipWith id
or better:
(><) :: [(a->b)] -> [a] -> [b]
(><) (f:fs) (x:xs) = (f x) : (fs >< xs)
(><) _ _ = []



The fibs example would now look like this:
take 10 fibs where fibs = 1 : 1 : (   (+)  :<  fibs  ><  tail fibs   )
instead of
take 10 fibs where fibs = 1 : 1 : zipWith (+) (fibs) (tail fibs)

What does you suggest/what's your oppinion to this?
(maybe other operators?)

- Marc