Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Remi Vanicat <vanicat@l...>
Subject: Re: [Caml-list] Question
"sebastien FURIC" <sebastien.furic@tni-valiosys.com> writes:

>  Hi,
>
>  What do you think of the following code?
>
> # type toto = Toto of int | Titi of string;;
> type toto = Toto of int | Titi of string
> # let test t t' = match t, t' with
>   | ((Toto _ | Titi _), Toto x | Toto x, (Toto _ | Titi _)) when x = 0
> -> "OK"
>   | _ -> "KO";;
> Characters 73-79:
> Warning: this pattern is unused.
>   | ((Toto _ | Titi _), Toto x | Toto x, (Toto _ | Titi _)) when x = 0
> -> "OK"
>                                           ^^^^^^

I can't answer to your question, but with your example, one can do a: 

# let test t t' = match t, t' with
  | ((Toto _ | Titi _), Toto 0
  | Toto 0, (Toto _ | Titi _)) when x = 0 -> "OK"
  | _ -> "KO";;

of course, this is not generalizable to any test.

-- 
Rémi Vanicat

-------------------
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