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 IAA10035; Wed, 25 Jun 2003 08:57:42 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA07704 for ; Wed, 25 Jun 2003 08:57:41 +0200 (MET DST) Received: from mail2.tpgi.com.au (mail.tpgi.com.au [203.12.160.58]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h5P6vcj10471 for ; Wed, 25 Jun 2003 08:57:39 +0200 (MET DST) X-Envelope-From: skaller@ozemail.com.au Received: from ozemail.com.au (203-219-234-178-syd-ts25-2600.tpgi.com.au [203.219.234.178]) (authenticated bits=0) by mail2.tpgi.com.au (8.12.9/8.12.9) with ESMTP id h5P6vNVx008150 for ; Wed, 25 Jun 2003 16:57:34 +1000 Message-ID: <3EF947D2.2050500@ozemail.com.au> Date: Wed, 25 Jun 2003 16:57:22 +1000 From: John Skaller User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2.1) Gecko/20010901 X-Accept-Language: en-us MIME-Version: 1.0 To: caml-list@inria.fr Subject: [Caml-list] Fun with fixpoints Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Kaspersky-Antivirus: Passed X-Spam: no; 0.00; ozemail:01 fixpoints:01 expressive:01 functors:01 toxteth:01 glebe:01 2037,:01 9660:01 0850:01 unify:01 ocaml:01 coerce:01 variants:01 subtype:01 coercion:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk type 't t0' = [`A of 't] type 't t1' = [`B of 't] type 't t' = [ 't t0' | 't t1'] (* unify *) type t0 = 't t0' as 't (* fix *) type t1 = 't t1' as 't (* fix *) type t = 't t' as 't (* fix *) type tt = [t0 | t1] (* unify *) Ocaml replies with .... type t = 'a t' as 'a type tt = [ `A of 'a t0' as 'a | `B of 'b t1' as 'b ] param pair ----- fix ----> pair | | unify unify | | | coerce | | V V param type --- fix ----> type This example shows how expressive polymorphic variants really are. In particular, they can not only union types, they can union type functors (parameterised types). Ocaml even knows the subtype relations: let f(x:tt) = (x:tt:>t) let f(x:t1):t = (x:t1:>t) let f(x:t1):tt = (x:t1:>tt but you have to use a double coercion to tell it. -- John Max Skaller, mailto:skaller@ozemail.com.au snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia. voice:61-2-9660-0850 ------------------- 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