package ppx_compose

  1. Overview
  2. Docs
Inlined Function Composition

Install

Dune Dependency

Authors

Maintainers

Sources

ppx_compose-0.0.3.tbz
sha256=a432e8543764b7c12e1f89e8710035f65b652bea188ee8d1242549d1bc033236
md5=afc8b36935f4a4d653d99b558c62b617

Description

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

Published: 04 Jun 2017

README

README.md

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

Dependencies (5)

  1. ocaml-migrate-parsetree < "2.0.0"
  2. topkg-jbuilder build
  3. topkg build
  4. jbuilder >= "1.0+beta7"
  5. ocaml >= "4.02.3"

Dev Dependencies

None

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.