caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Pierre-Alexandre Voye <ontologiae@gmail.com>
To: caml-list <caml-list@inria.fr>
Subject: [Caml-list] How an exception could be an argument
Date: Fri, 17 Feb 2012 19:16:42 +0100	[thread overview]
Message-ID: <CANnJ5GdKgpk_E1F3B9GDS-SC3EnnvLTTOgGRgEsvbZL0S_VGag@mail.gmail.com> (raw)

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

Hello, I'm trying to implement a scala concept "partial application" in
which one can chains pattern matching function. If the first failed, the
second is tried.
It seems it is impossible to give an exception as argument to a function.



exception Nothing;;

let (<|||>) a b = try a
with

  | Nothing ->  (try b
with

                   | Nothing -> raise
Nothing);;

val ( <|||> ) : 'a -> 'a -> 'a = <fun>


(raise Nothing) <|||>
"jj";;

Exception: Nothing.


But if I try :
try (raise Nothing)
with

  | Nothing ->  (try
"jj"with

                   | Nothing -> raise
Nothing);;

- : string = "jj"

Is there a workaround ?


Regards,
P-A
-- 
---------------------
https://twitter.com/#!/ontologiae/
http://linuxfr.org/users/montaigne

[-- Attachment #2: Type: text/html, Size: 3893 bytes --]

             reply	other threads:[~2012-02-17 18:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-17 18:16 Pierre-Alexandre Voye [this message]
2012-02-17 18:33 ` Edgar Friendly
2012-02-17 18:49 ` Vincent Aravantinos
2012-02-17 19:31 ` Tiphaine Turpin

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=CANnJ5GdKgpk_E1F3B9GDS-SC3EnnvLTTOgGRgEsvbZL0S_VGag@mail.gmail.com \
    --to=ontologiae@gmail.com \
    --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).