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: skaller <skaller@o...>
Subject: Re: [Caml-list] tpyping question
On Mon, 2003-08-11 at 12:51, Oleg Trott wrote:

> This is indeed very odd, because the equivalent
> 
> let f a = match a with `A -> g a | `B _ -> g a | _ -> g a
> 
> works fine.

Yes, but there are some strange things happen with
polymorphic variants -- I mean sometimes you need a
coercion and sometimes a double coercion, and I
don't have that strong a grasp on the typing to really
be sure what's a limitation of the inference engine
and whats not: as a human I sometimes read 'intent'
into something that the compiler doesn't :-)

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.


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