From: Tiphaine Turpin <tturpin@crim.ca>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] tpyping question
Date: Mon, 11 Aug 2003 15:02:22 -0400 [thread overview]
Message-ID: <3F37E83E.5@crim.ca> (raw)
In-Reply-To: <1060625815.16392.8.camel@localhost.localdomain>
Hello,
here is another solution, but it's not better if there are many cases
match x, 0 with
| `A n, _
| `B, n -> g n
| `C x, _ -> ...
;;
skaller wrote:
>On Mon, 2003-08-11 at 15:18, Karl Zilles wrote:
>
>
>>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
>> ...
>>
>>
>
>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 ...
>| ......
>
>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, hence my suggestion,
>in which the handler is local and there's no repetition.
>
>
>
>-------------------
>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
>
>
-------------------
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
prev parent reply other threads:[~2003-08-11 19:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-11 1:13 skaller
2003-08-11 2:46 ` Jacques Garrigue
2003-08-11 4:30 ` skaller
2003-08-12 3:24 ` Jacques Garrigue
2003-08-11 2:51 ` Oleg Trott
2003-08-11 4:39 ` skaller
2003-08-11 5:18 ` Karl Zilles
2003-08-11 18:13 ` Karl Zilles
2003-08-11 18:16 ` skaller
2003-08-11 19:02 ` Remi Vanicat
2003-08-12 4:25 ` skaller
2003-08-11 19:02 ` Tiphaine Turpin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3F37E83E.5@crim.ca \
--to=tturpin@crim.ca \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox