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: Pierre Weis <Pierre.Weis@i...>
Subject: Re: [Caml-list] variant with tuple arg in pattern match?
[...]
> > 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.

Cheers,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/


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