Browse thread
[Caml-list] tpyping question
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Remi Vanicat <vanicat@l...> |
| Subject: | Re: [Caml-list] tpyping question |
skaller <skaller@ozemail.com.au> writes: > In reality there are 20 tags, not just the 2 shown. > So I'd have to write: > > match x with > | ..... > | `A _ as y > | `B _ as y -> let (i,j) = match y with `A v->v | `B u -> (u,0) in ... > | ...... If `A (x,y) and `B x have a link (as it seem in your example) I would have define the type type aorB = [`A of int * int | `B of int] and then your code become : match x with | ..... | #aorB as y -> let (i,j) = match y with `A v->v | `B u -> (u,0) in ... | ...... by the way, you only need one as for the | `A ... | `B ... pattern there is only one as, not two . > > repeating the tags, In fact I do this sometimes, but it's also poor > style repeating the tags. So I have 2 choices of poor style: > repeat tags or delocalise handler, repeat tags is the best way IMHO (to avoid to correct the bugs in only one of the two branch). -- Rémi Vanicat vanicat@labri.u-bordeaux.fr http://dept-info.labri.u-bordeaux.fr/~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