Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] failwith, raise and type inference
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Ker Lutyn <ker527mail@y...>
Subject: Re: [Caml-list] failwith, raise and type inference
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