Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] variant with tuple arg in pattern match?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Sven LUTHER <luther@d...>
Subject: Re: [Caml-list] variant with tuple arg in pattern match?
On Mon, Apr 09, 2001 at 05:57:00PM +0200, Pierre Weis wrote:
> [...]
> > > I suggest to explicitely annotate the constructor definitions as in:
> > > 
> > > type t =
> > > | C : int -> int -> t
> > 
> > Now that's an interesting idea! 
> > 
> > > This notation is explicit, intuitive, and allows refined type checking
> > > in some cases (for instance
> > > type 'a t = C : int -> bool -> (int * bool) t).
> > > 
> > > Last but not least, this suggestion is a pure extension of the actual
> > > syntax, compatible with the current notations. (We can still allow the
> > > form ``C of ty'' as a short hand for C of ty -> t).
> > 
> > You meant C : ty -> t of course.
> 
> Oups. Thank you for the correction.
> 
> > Getting back to the original problem
> > and confusing cases, would you still want the shorthands for the cases, 
> > say 
> > 
> > type t = C : int -> int -> t <=> type t = C of int * int ?
> > type t = C : int * int -> t  <=> type t = C of (int * int)
> > 
> > to be fixed so that the confusions don't arise anymore, or would you just 
> > want to deprecate the earlier notations?
> >
> > -- Brian
> 
> I suggest to support those equivalences while deprecating the earlier
> notations (after a while, so that the transition would be
> smooth). This would be easy if Caml users vote for the new notation (I
> mean if they intensively use the new notation in their programs). I
> think the new notation is so clean and easy that we would adopt it
> without discussion as soon as it is available in the language.

And it would permit us to do :

type t = A of int -> int

err that is 

type t = A : int -> int

instead of having to add parentheses around it ?

# type t = A of int -> int ;;
Syntax error
# type t = A of (int -> int) ;;
type t = A of (int -> int)

Friendly,

Sven Luther
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr