From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id IAA21123 for caml-red; Mon, 16 Oct 2000 08:18:39 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA19085 for ; Mon, 16 Oct 2000 01:43:43 +0200 (MET DST) Received: from dopamine.iq.org (dopamine.iq.org [203.4.184.129]) by nez-perce.inria.fr (8.10.0/8.10.0) with ESMTP id e9FNhGD16615 for ; Mon, 16 Oct 2000 01:43:32 +0200 (MET DST) Received: by dopamine.iq.org (Postfix, from userid 110) id EA730111EA; Mon, 16 Oct 2000 10:42:04 +1100 (EST) To: caml-list@inria.fr Subject: list composition functions Cc: proff@iq.org From: Julian Assange Date: 16 Oct 2000 10:42:03 +1100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: weis@pauillac.inria.fr Imagine you have the follow three functions, let mirror x = [x;x] let plus1 x = [x+1] let none x = [] I'm trying to define an operator (>>) that will then operate like so (mirror >> mirror >> plus1) [1] [2;2;2;2] let (>>) a b = function x -> let rec loop = function [] -> [] | hd::tl -> let rec loop2 = function [] -> loop tl | hd::tl -> b hd @ loop2 tl in loop2 (a hd) in loop x # (>>);; - : ('a -> 'b list) -> ('b -> 'c list) -> 'a list -> 'c list = While this looks okay, and works fine for two applications, the list type keeps on growing with each partial application. plus1 >> plus1 >> plus1 >> plus1;; - : int list list list -> int list = # Is there anyway I can prevent this, short of making plus1, etc symmetric with respect to their argument types?