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 OAA21468; Thu, 18 Apr 2002 14:53:17 +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 OAA21464 for ; Thu, 18 Apr 2002 14:53:16 +0200 (MET DST) Received: from favie.faith.gr.jp (favie.faith.gr.jp [61.127.175.250]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g3ICrEb26704 for ; Thu, 18 Apr 2002 14:53:14 +0200 (MET DST) Received: from localhost (dhcp7.faith.gr.jp [192.168.1.17]) by favie.faith.gr.jp (8.9.3/8.9.3) with ESMTP id VAA26468; Thu, 18 Apr 2002 21:52:56 +0900 To: pixel@mandrakesoft.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] Is a Cow an Animal? In-Reply-To: References: <3CBE2CC8.1030407@ozemail.com.au> X-Mailer: Mew version 1.94.2 on Emacs 20.7 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20020418215232T.garrigue@kurims.kyoto-u.ac.jp> Date: Thu, 18 Apr 2002 21:52:32 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Pixel > * one pb was: > > let is_meat_ = function > | `Beef | `Dead_rabbit | `Dead_human -> true > | _ -> false > > which type "[> `Beef | `Dead_rabbit | `Dead_human] -> bool" doesn't allow > is_meat_ (food : [`Grass]) This is to avoid _too_ weak typings, which would allow for bad typos. The more direct solution is let is_meat_ = function | #meat_kind -> true | #vegetable_kind -> false > * I still can't manage to have: > > new_human : int -> ([ `Dead_human], [< food_kind]) animal > all i got is > new_human : int -> ([ `Dead_human], _[< food_kind]) animal Classical solution is eta-expansion let new_human n : ([`Dead_human], [< food_kind ]) animal = new animal `Human `Dead_human n should work. Basically, for closed world problems polymorphic variants work generally better than object encodings. If you want it open world, this gets more subtle. Jacques Garrigue ------------------- 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