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 NAA23504; Tue, 10 Apr 2001 13:47:45 +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 NAA23500 for ; Tue, 10 Apr 2001 13:47:44 +0200 (MET DST) Received: from iona.dcs.gla.ac.uk (iona.dcs.gla.ac.uk [130.209.240.35]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f3ABlhb22573; Tue, 10 Apr 2001 13:47:43 +0200 (MET DST) Received: from crab.dcs.gla.ac.uk ([130.209.241.150]) by iona.dcs.gla.ac.uk with esmtp (Exim 3.13 #1) id 14mwcU-0004CF-00; Tue, 10 Apr 2001 12:47:38 +0100 Received: by crab.dcs.gla.ac.uk (8.8.8+Sun/Dumb) id MAA11108; Tue, 10 Apr 2001 12:47:38 +0100 (BST) From: reig@dcs.gla.ac.uk Message-Id: <200104101147.MAA11108@crab.dcs.gla.ac.uk> Subject: Re: [Caml-list] variant with tuple arg in pattern match? To: Michel.Mauny@inria.fr Date: Tue, 10 Apr 2001 12:47:37 +0100 (BST) Cc: caml-list@inria.fr In-Reply-To: <20010410133239.B13189@quincy.inria.fr> from "Michel Mauny" at Apr 10, 2001 01:32:39 PM X-Mailer: ELM [version 2.5 PL3] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Michel Mauny wrote: > Sure. With CamlP4's revised syntax, you would write this as > > type t 'a =3D > I of int > | B of bool > | N of (t 'a) and (t 'a) (* parens probably unnecessary *) > | Uncurried of int * int > > > Moreover, the last part (-> 'a t) is the same for all constructors and > > can be omitted like you do in haskell (so that Xavier is happier :) > >=20 > > type 'a t =3D > > Int : int > > | Bool : bool > > | Node : 'a t -> 'a t > > | Uncurried : int * int > > I'm afraid the Node case is ambiguous, here. > > Is the type of Node 'a t -> 'a t -> 'a t > or is it ('a t -> 'a t) -> 'a t ? > > In other words, you can't know wether Node carries functions, or is > curried. Like in haskell, if it *looks* curried, it *is* curried. data T a = Curried (T a) (T a) | Function (T a -> T a) Main> :i T -- type constructor data T a -- constructors: Curried :: T a -> T a -> T a Function :: (T a -> T a) -> T a Even in ocaml's current syntax, you need parens for functions in datatypes: # type t = F of int -> int;; Syntax error # type t = F of (int -> int);; type t = F of (int -> int) Maybe other syntax of disambiguating this case are better, I'm proposing the one I know, which seems quite regular. Fermin Reig ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr