Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Q: Correct locations for macro camlp4 extensions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Michael Alexander Hamburg <hamburg@f...>
Subject: Re: [Caml-list] Re: Correct locations for macro camlp4 extensions


On Tue, 24 Aug 2004, Jan Kybic wrote:

> > Which Haskell operator features does this emulate?  I know you can make an
> > operator without any camlp4 that does right-associative application, basically
>
> What I had in mind is function decomposition '.', you write
>
> ( f . g . h ) x     instead of        h ( g ( f x ) )
>
> The other operator is '$':
>
> f $ g $ h x         instead of        f ( g ( h x ) )
>
> both can save a lot of parentheses.
>

... snip ...

>    (* infix operator $, functional composition *)
>   expr: AFTER "apply"
>    [[ f = expr; "$"; g = expr -> <:expr< fun x -> $f$ ($g$ x) >> ]];
>
>

I don't think this is what you want.  The Haskell $ is a regular
right-associative operator; in particluar, it will treat

f $ g x y
as
f (g x y)
whereas this code will treat it as
f (g x) y

You can do it the Haskell way in O'Caml too, you would just have to make $
right-associative, which shoulndn't be so hard (I think the example for o
can be tweaked to do it).

Mike

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