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?
> On Sun, 8 Apr 2001, Pierre Weis wrote:
> > I suggest to explicitely annotate the constructor definitions as in:
> > 
> > type t =
> > | C : int -> int -> t
> > This notation is explicit, intuitive, and allows refined type checking
> > in some cases (for instance
> > type 'a t = C : int -> bool -> (int * bool) t).
> 
> How does this interact with pattern matching ?

As usual. There would be no minteraction with the pattern matching
facility of Objective Caml.

[...]
> For instance, with the declaration:
>   type 'a t = A : int t | B : 'a -> 'a t
> do you issue a warning for:
>   function B x -> x
> ?

Yes, as usual: the constructor A is not covered by this matching.

> -- 
>   Alain Frisch

One more, there is no interaction with the pattern matching algorithm,
and as Daniel said, the syntax would just prevent you from trying to
misuse the arguments of a constructor.

Hope this helps,

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