From: Tiphaine Turpin <tiphaine.turpin@free.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] How an exception could be an argument
Date: Fri, 17 Feb 2012 20:31:34 +0100 [thread overview]
Message-ID: <4F3EAB16.7060803@free.fr> (raw)
In-Reply-To: <CANnJ5GdKgpk_E1F3B9GDS-SC3EnnvLTTOgGRgEsvbZL0S_VGag@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2535 bytes --]
This behavior is expected given than OCaml is strict, and your operator
<|||> would be an ordinary function (unlike || and &&). You have to use
either functions (or lazy values) instead of expressions, or options
instead of exceptions.
Tiphaine
Le 17/02/2012 19:16, Pierre-Alexandre Voye a écrit :
> 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/ <https://twitter.com/#%21/ontologiae/>
> http://linuxfr.org/users/montaigne
>
[-- Attachment #2: Type: text/html, Size: 4884 bytes --]
prev parent reply other threads:[~2012-02-17 18:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-17 18:16 Pierre-Alexandre Voye
2012-02-17 18:33 ` Edgar Friendly
2012-02-17 18:49 ` Vincent Aravantinos
2012-02-17 19:31 ` 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=4F3EAB16.7060803@free.fr \
--to=tiphaine.turpin@free.fr \
--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