caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Ker Lutyn <ker527mail@yahoo.com>
To: Pierre Weis <pierre.weis@inria.fr>, Luc Maranget <Luc.Maranget@inria.fr>
Cc: pguyot@kallisys.net, caml-list@inria.fr
Subject: Re: [Caml-list] failwith, raise and type inference
Date: Mon, 5 Apr 2004 15:52:38 -0700 (PDT)	[thread overview]
Message-ID: <20040405225238.33087.qmail@web40613.mail.yahoo.com> (raw)
In-Reply-To: <200404022028.WAA20083@pauillac.inria.fr>

I wonder if we could have Haskell's $ operator added to OCaml. It would make
this idiom and a lot of my code nicer.

    failwith $ "foo" ^ "bar"

Defining it myself as

    let ($) f x = f x

doesn't work because of precedence and associativity. The caml sources
frequently define

    let (++) x f = f x

which is a similar idea - but lots of times Haskell's $ is what you want.



--- Pierre Weis <pierre.weis@inria.fr> wrote:
> [...]
> > Admitedly caml syntax is not very  beginner friendly.
> > But the observed parsing has some internal logics.
> > 
> > On usualy understand that  f x + y is in fact  (f x) + y
> > But here, with failwith being a ``special'' function and ^ a ``special''
> > operator, well...
> 
> That could be part of the problem: failwith is not ``special'' nor is ^,
> hence the regular treatment of f x ^ y as (f x) ^ y and failwith x ^ y
> as (failwith x) ^ y.
> 
> Operator precedence in Caml has been carefully crafted, you should
> have a look at the programming guide lines that gives some hints on the
> internal logics of some parts of the parsing, in the section
> 
>    When to use parentheses within an expression
> 
> Best regards,
> 
> Pierre Weis
> 
> INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/
> 
> 
> -------------------
> 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


__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway 
http://promotions.yahoo.com/design_giveaway/

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


  reply	other threads:[~2004-04-05 22:52 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-02 13:41 Paul Guyot
2004-04-02 13:49 ` Frederic van der Plancke
2004-04-02 13:56   ` Paul Guyot
2004-04-02 13:51 ` Nicolas Cannasse
2004-04-02 13:59 ` Correnson Loïc
2004-04-02 14:09 ` Luc Maranget
2004-04-02 19:39   ` [Caml-list] weird floating poing behavior on windows Zeno Lee
2004-04-02 20:03     ` Greg Bacon
2004-04-02 20:07     ` David Brown
2004-04-02 20:31       ` Zeno Lee
2004-04-02 20:50         ` Pierre Weis
2004-04-02 22:01         ` Brian Hurt
2004-04-02 21:58     ` Brian Hurt
2004-04-02 20:28   ` [Caml-list] failwith, raise and type inference Pierre Weis
2004-04-05 22:52     ` Ker Lutyn [this message]
2004-04-06  1:07       ` Jacques Garrigue
2004-04-06  5:23         ` Issac Trotts
2004-04-06 15:15           ` skaller
2004-04-06  1:15       ` Christophe TROESTLER
2004-04-06  7:05         ` skaller
2004-04-06 11:29           ` Eric C. Cooper
2004-04-09  7:18           ` Christophe TROESTLER
2004-04-09  7:32             ` Xavier Leroy
2004-04-09  8:03               ` skaller

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=20040405225238.33087.qmail@web40613.mail.yahoo.com \
    --to=ker527mail@yahoo.com \
    --cc=Luc.Maranget@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=pguyot@kallisys.net \
    --cc=pierre.weis@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).