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 KAA26557; Wed, 5 Nov 2003 10:46:21 +0100 (MET) 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 KAA26564 for ; Wed, 5 Nov 2003 10:46:19 +0100 (MET) Received: from postfix3-2.free.fr (postfix3-2.free.fr [213.228.0.169]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hA59kJ113021 for ; Wed, 5 Nov 2003 10:46:19 +0100 (MET) Received: from free.fr (lns-th2-1-82-64-7-188.adsl.proxad.net [82.64.7.188]) by postfix3-2.free.fr (Postfix) with ESMTP id 49A24C43C; Wed, 5 Nov 2003 10:46:18 +0100 (CET) Message-ID: <3FA8D361.4050206@free.fr> Date: Wed, 05 Nov 2003 11:39:29 +0100 From: Julien Demouth User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20031008 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dustin Sallings , caml-list@inria.fr Subject: Re: [Caml-list] function overloading References: <0F0B3332-0F6E-11D8-85C9-000393CFE6B8@spy.net> In-Reply-To: <0F0B3332-0F6E-11D8-85C9-000393CFE6B8@spy.net> X-Enigmail-Version: 0.76.4.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 gcaml:01 gcaml:01 extensional:01 furuse:01 generics:01 bool:01 bool:01 ocaml:01 ocaml:01 overloading:01 int:01 int:01 polymorphic:01 match:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Dustin Sallings wrote: > > I swear I found an example demonstrating how to do pattern matching > based on the type of an argument, but every pattern matching example I > can find now seems to be focused on value and not type. > You've probably read an example of what GCaml offers. GCaml is an extension of OCaml allowing some "extensional polymorphic extensions". But you have to know that it is based on an old OCaml version. Have a look at: http://pauillac.inria.fr/~furuse/generics/ > I'm trying to do something like this: > > let print_poly x = match x with > | (x: bool) -> print_bool x > | (x: int) -> print_int x > ;; > > Can someone tell me what I'm doing wrong (or perhaps tell me why I > shouldn't be doing this at all)? > It cannot work with OCaml because all the expressions in a pattern matching have to have the same type. The pattern matching is based on variables values and not on their types. It is how the language works. Julien ------------------- 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