caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques-Henri Jourdan <jacques-henri.jourdan@normalesup.org>
To: caml-list@inria.fr
Subject: Re: [Caml-list] ocaml 4.03 and warning 52 : argument of this constructor should not be matched against a constant pattern
Date: Wed, 27 Apr 2016 11:43:20 +0200	[thread overview]
Message-ID: <572089B8.8090207@normalesup.org> (raw)
In-Reply-To: <32C540F73D89478D9E6D2AF2599F639F@erratique.ch>

[-- Attachment #1: Type: text/plain, Size: 746 bytes --]



On 04/27/2016 11:36 AM, Daniel Bünzli wrote:
> Le mercredi, 27 avril 2016 à 11:22, William a écrit :
>> How are we supposed to handle this nicely with the standard library ? Is
>> there a better approach to catch those exceptions ?
> Capture them immediately around the function call that raises with a _ pattern.  
> For example:  
>
> match (try Some (List.hd lst) with Failure _ -> None) with
> | None -> Printf.printf "empty list\n"
> | Some hd -> …
>
> That's the way these functions should have been defined in the first place.
>
> Best,  
>
> Daniel
>
>
>
Or, with the new pattern matching with exception syntax :

match List.hd lst with
| exception Failure _ -> Printf.printf "empty list\n"
| hd -> ...


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2016-04-27  9:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-27  9:22 William
2016-04-27  9:28 ` David Allsopp
2016-04-27  9:36 ` Daniel Bünzli
2016-04-27  9:43   ` Jacques-Henri Jourdan [this message]
2016-04-27  9:51     ` Roberto Di Cosmo
2016-04-27 10:00     ` Daniel Bünzli
2016-04-27 10:04       ` Jacques-Henri Jourdan
2016-04-28  7:25         ` Goswin von Brederlow
2016-04-27 11:01 ` Gabriel Scherer
2016-04-27 17:17   ` Adrien Nader
2016-04-27 18:20     ` Gabriel Scherer

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=572089B8.8090207@normalesup.org \
    --to=jacques-henri.jourdan@normalesup.org \
    --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;
as well as URLs for NNTP newsgroup(s).