package ppx_repr

  1. Overview
  2. Docs
PPX deriver for type representations

Install

Dune Dependency

Authors

Maintainers

Sources

repr-fuzz-0.2.1.tbz
sha256=0ca29b7273870190b724e6db1f782980c175c50d9a208ff8ad351cbbb85a7fb1
sha512=5b7d32724e70ffcbc15bdefc71871148d0f2b743f6d664891e1126d194d3752dfb7715dbbe6046bcbd6f19c384a840b3e66c4130b5bb663580aeb6d697d7a20d

doc/src/ppx_repr.lib/utils.ml.html

Source file utils.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
open Ppxlib

let ( >> ) f g x = g (f x)
let ( >|= ) x f = List.map f x

module Make (A : Ast_builder.S) : sig
  val compose_all : ('a -> 'a) list -> 'a -> 'a
  (** Left-to-right composition of a list of functions. *)

  val lambda : string list -> expression -> expression
  (** [lambda \[ "x_1"; ...; "x_n" \] e] is [fun x1 ... x_n -> e] *)

  val arrow : core_type list -> core_type -> core_type
  (** [arrow \[ "t_1"; ...; "t_n" \] u] is [t_1 -> ... -> t_n -> u] *)
end = struct
  open A

  let compose_all l x = List.fold_left ( |> ) x (List.rev l)
  let lambda = List.map (pvar >> pexp_fun Nolabel None) >> compose_all
  let arrow = List.map (ptyp_arrow Nolabel) >> compose_all
end
OCaml

Innovation. Community. Security.