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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Damien Doligez <Damien.Doligez@i...>
Subject: Re: [Caml-list] polymorphic type constructor deconstructor
On Friday, June 6, 2003, at 11:30 PM, Jeffrey J. Cook wrote:

> let request = REQ_do_this 5 in
> let reply = Socket.client "mysocket" request in
> let success =
>   match reply with
>   | REPLY_do_this x -> x
>   | _ -> failwith "this case shouldn't happen and is annoying"

You can use patterns in the left-hand part of a let:

let request = REQ_do_this 5 in
let reply = Socket.client "mysocket" request in
let REPLY_do_this success = reply in
... success ...

The compiler will complain about a non-exhaustive pattern matching,
but that's only fair.

-- Damien

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