Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
'a Set?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-01-26 (16:16)
From: Jacques Carette <carette@m...>
Subject: RE: [Caml-list] 'a Set?
This (~%) operator is called 'flip' in Haskell, and it is used there all the
time.  It is kind-of surprising that flip is not in Pervasives [as has been
mentionned before].


-----Original Message-----
From: []
On Behalf Of Alex Baretta
Sent: January 26, 2005 11:00 AM
Subject: Re: [Caml-list] 'a Set?

Jacques Garrigue wrote:
> From: Radu Grigore <>

> If you respect this convention, the type tells you about the semantics
> :-)

There are two different patterns for function signatures: the Hashtbl 
pattern and the Map pattern. Both are "good", depending on the context. 
Since I need both approaches I have come up with a little trick to get 
the best of both worlds.

# let (~%) f = fun x y -> f y x

The ~% operator swaps the first and the second parameter in a function 
call. The following is a trivial example of its use.

# ~% Printf.kprintf "Hello %s!" failwith "World";;
Exception: Failure "Hello World!".