From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id MAA20969; Mon, 23 Jun 2003 12:08:45 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 MAA21024 for ; Mon, 23 Jun 2003 12:08:44 +0200 (MET DST) Received: from fichte.ai.univie.ac.at (fichte.ai.univie.ac.at [131.130.174.156]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h5NA8hD04710 for ; Mon, 23 Jun 2003 12:08:43 +0200 (MET DST) Received: from fichte.ai.univie.ac.at (markus@localhost [127.0.0.1]) by fichte.ai.univie.ac.at (8.12.3/8.12.3/Debian-6.4) with ESMTP id h5NA8gqF004430; Mon, 23 Jun 2003 12:08:42 +0200 Received: (from markus@localhost) by fichte.ai.univie.ac.at (8.12.3/8.12.3/Debian-6.4) id h5NA8gH2004429; Mon, 23 Jun 2003 12:08:42 +0200 Date: Mon, 23 Jun 2003 12:08:42 +0200 From: Markus Mottl To: John Max Skaller Cc: Michal Moskal , caml-list@inria.fr Subject: Re: [Caml-list] First order compile time functorial polymorphism in Ocaml Message-ID: <20030623100842.GA3386@fichte.ai.univie.ac.at> Mail-Followup-To: John Max Skaller , Michal Moskal , caml-list@inria.fr References: <3EF5F48E.6010209@ozemail.com.au> <20030622190353.GA9806@roke.freak> <3EF6796E.20004@ozemail.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3EF6796E.20004@ozemail.com.au> User-Agent: Mutt/1.4.1i X-Spam: no; 0.00; caml-list:01 functorial:01 foo:01 generalizing:01 modelling:01 datatypes:01 meijer:01 ocaml:01 mottl:02 compile:02 unit:03 wrote:03 recursive:03 constructor:03 exponential:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, 23 Jun 2003, John Max Skaller wrote: > >For example consider: > > > >type 'a t = Foo 'a -> unit > > > >To map : 'a t -> 'b t here, you need f : 'b -> 'a. > > Ah, ok, exponential is contravariant. This problem (generalizing fold/unfold to exponentials that use the type constructor also in contravariant positions) is solved by applying a solution for modelling recursive datatypes as fixed points of difunctors. See the following very nice paper for details: Title: Bananas in space: extending fold and unfold to exponential types Authors: Erik Meijer and Graham Hutton What you need in your example is a cofunctor "f" together with a function "comap", which takes the functional (a -> b) to (f b -> f a). In the mixed case (co- and contravariant occurrences in the same type definition) you need difunctors (see paper for details). Regards, Markus Mottl -- Markus Mottl http://www.oefai.at/~markus markus@oefai.at ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners