package ppx_deriving_crowbar

  1. Overview
  2. Docs
ppx_deriving plugin for crowbar generators

Install

Dune Dependency

Authors

Maintainers

Sources

0.1.1.tar.gz
md5=259d96c464f56c2dbea22746f0125f79

Description

Published: 28 Apr 2018

README

ppx_deriving_crowbar

What is this?

ppx_deriving_crowbar is a ppx_deriving plugin for generating crowbar generators.

Examples:

type number = int [@@deriving crowbar]

will result in a function which maps Crowbar's int generator primitive to a t:

let number_to_crowbar : t Crowbar.gen = Crowbar.(map [int] (fun a -> a))

You can specify a custom generator to replace the automatically derived one with [@generator f]. (This is useful in large mutually-recursive type definitions, where you want most of the automatically derived functions.) For example:

type p = int
and q = p list
and r = q list [@generator Crowbar.const []]
[@@deriving crowbar]

to create the following functions:

let p_to_crowbar : p Crowbar.gen = Crowbar.(map [int] fun a -> a)
and q_to_crowbar : q Crowbar.gen = Crowbar.list p_to_crowbar
and r_to_crowbar : r Crowbar.gen = Crowbar.const []

Note that types named t get functions named to_crowbar, rather than t_to_crowbar, as is the convention for ppx_deriving plugins.

Examples

ppx_deriving_crowbar is used in tandem with ppx_import to automatically generate OCaml ASTs to test ocaml-migrate-parsetree in ocaml-test-omp, and to generate certificates to test ocaml-x509 in ocaml-test-x509.

Dependencies (6)

  1. crowbar
  2. ppx_tools
  3. ppx_deriving >= "4.1.5" & < "4.3"
  4. ocamlfind build
  5. ocamlbuild build
  6. ocaml >= "4.06.0"

Dev Dependencies

None

Used by

None

Conflicts

None