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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Karl Zilles <zilles@1...>
Subject: Re: [Caml-list] tpyping question
skaller wrote:
> BTW: something I've needed is like this:
> 
> type [`A of int * int | `B of int]
> let f x = match x with
> | `A (i,j)
> | `B i with j=0 -> ....
> (*     ********   *)
> 
> At the moment, I have to code this as:
> 
> let f x =
>   let g i j = ... in
>   match x with
>   | `A (i,j) -> g i j
>   | `B i -> g i 0
> 
> delocalising the case handling code.
> 

Wouldn't it be more natural to write:

let f x =
    let (i,j) = match x with
	| `A v -> v
         | `B u -> (u,0) in
    ...


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