## ppx_compose

Author | Petter A. Urkedal | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

License | LGPL-3 with OCaml linking exception | |||||||||||||||||||||

Homepage | https://github.com/paurkedal/ppx_compose/ | |||||||||||||||||||||

Issue Tracker | https://github.com/paurkedal/ppx_compose/issues | |||||||||||||||||||||

Maintainer | paurkedal@gmail.com | |||||||||||||||||||||

Dependencies |
| |||||||||||||||||||||

Available | ocaml-version >= "4.02.3" | |||||||||||||||||||||

Published | Jun 4, 2017 | |||||||||||||||||||||

Source [http] | https://github.com/paurkedal/ppx_compose/releases/download/v0.0.3/ppx_compose-0.0.3.tbz afc8b36935f4a4d653d99b558c62b617 | |||||||||||||||||||||

Statistics | Installed once last month. | |||||||||||||||||||||

Edit | https://github.com/ocaml/opam-repository/tree/master/packages/ppx_compose/ppx_compose.0.0.3/opam |

#### Inlined Function Composition

`ppx_compose`

is a simple syntax extension which rewrites code containing
function compositions into composition-free code, effectively inlining the
composition operators. The following two operators are supported

```
let (%) g f x = g (f x)
let (%>) f g x = g (f x)
```

Corresponding definitions are not provided, so partial applications of `(%)`

and `(%>)`

will be undefined unless you provide the definitions.

The following rewrites are done:

A composition occurring to the left of an application is reduced by applying each term of the composition from right to left to the argument, ignoring associative variations.

A composition which is not the left side of an application is first turned into one by η-expansion, then the above rule applies.

Any partially applied composition operators are passed though unchanged.

E.g.

```
h % g % f ==> (fun x -> h (f (g x)))
h % (g % f) ==> (fun x -> h (f (g x)))
(g % f) (h % h) ==> g (f (fun x -> h (h x)))
```

No package is dependent |