package ppx_fun
Ppx rewriter for fun
Install
Dune Dependency
Authors
Maintainers
Sources
ppx_fun-0.0.9.tbz
sha256=f3f58f3d50222d50b255766972d28e48b447dba792f133451e24ff9a1c886bdb
sha512=7f2b887d0e3b3e9efb085f0c144b38a26639209ade7cf0704a0deb7d3a0424e81c07db725147132de3d4c68ff4c4f14118414325e675138e2a82c0c5987aaa72
Description
Ppx rewriter for fun
README
ppx_fun — shorthand syntax for anonymous functions
ppx_fun is PPX rewriter that provides simplified syntax for anonymous functions via extensions: [%f ...]
and [%f_ ...]
.
Examples
(* anonymous placeholder: *)
List.iter lst ~f:[%f Printf.printf "element: %d" __]
(* function translated to: (fun v -> Printf.printf "element: %d" v) *)
(* positional placeholders: *)
List.map lst ~f:[%f _1 * _2]
(* translated to: (fun v1 v2 -> v1 * v2) *)
(* unused positional placeholders: *)
some_func |> [%f _1 ^ _3]
(* translated to: (fun v1 _v2 v3 -> v1 ^ v3) *)
(* 0-ary function: *)
async_func >>= [%f other_async_func var ]
(* translsated to: (fun () -> other_async_func var) *)
(* drop argument: *)
return_smth >>= [%f_ ignore_and_continue ()]
(* translated to*)
Note: function parameters are named with line info to avoid name-clashing.
Installation
ppx_fun can be installed with opam
:
opam install ppx_fun
Usage
Add ppx_fun
as dependency to your opam
file, and this to your _tags
:
<src/*.ml>: package(ppx_fun)
Differences with ppx_lambda
ppx_lambda is another ppx rewriter with aim to provide lightweight syntax for anonymous functions. With contrast to ppx_lambda
, this packages is:
Maintained %)
Available via opam
Uses extension syntax, so no strange conflicts/errors
Build instruction
make
to build rewriter and run tests.
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page