What it does

ppx_partial is a preprocessor that makes it possible to do partial applications that omit any parameter of a function, rather than necessarily a suffix of unlabelled arguments with currying:

something_that_returns_a_string ()
|> Base.String.drop_suffix __ 1
|> Stdio.Out_channel.write_all "/tmp/z" ~data:__

is turned into:

something_that_returns_a_string ()
|> (fun x -> Base.String.drop_prefix x 1)
|> (fun x -> Stdio.Out_channel.write_all "/tmp/z" ~data:x)

In the general case, the ppx ensures that all parameters are executed exactly once, just like with a regular partial application. For instance, these two expressions have the exact same performance :

List.filter (Re.execp (Re.compile re) __) l
List.filter (Re.execp (Re.compile re)) l

As a slight generalization, field accesses and sum constructors are allowed: List.map __.field l, List.map (Some __) l.

As an other slight generalization, it is possible to omit the function instead of an argument: Option.iter o ~f:(__ ()) which means Option.iter o ~f:(fun f -> f ()).

What it doesn't do

This is not a general lighter syntax for short anonymous functions. If you want a lightweight syntax for (fun x -> f (g x)) or (fun x -> x * 2 + 1), this ppx isn't providing such things.

Why

The purpose is simply convenience. To be more specific :