package ppx_gen_rec
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
sha256=fe6323e544f6d8a406572d6c8e01283a03f3c826327833ed58960d0ef43d9e59
sha512=23ecf170f0792c28d0535fba43d6ae51b0a063974ba1b729ebf0af3d8a088b31f4166296fa0e457623384f11142c8430bf13525f721dfbabc60688fad9c92ab9
Description
In a recursive module expression, the struct can be derived from the signature automatically by the compiler. This package does the same thing, but doing it this way allows ppx_deriving to transform the signature and struct separately.
Added to opam-repository:
README
ocaml-ppx_gen_rec
A ppx rewriter that transforms a recursive module expression into a struct.
If you write a recursive module like this:
module rec Foo : sig
type t = string
end = FooThe compiler treats it like you wrote:
module rec Foo : sig
type t = string
end = struct
type t = string
endIf you try to use ppx_deriving, you get a Undefined_recursive_module exception, because ppx_deriving generates the signature but not the implementation:
module rec Foo : sig
type t = string [@@deriving show]
end = Foo
(* is like writing *)
module rec Foo : sig
type t = string
val show: t -> string
end = struct
type t = string
let show _ = raise Undefined_recursive_module
endUse ppx_gen_rec before ppx_deriving to generate an explicit struct, which will cause ppx_deriving to generate an implementation:
module%gen rec Foo : sig
type t = string [@@deriving show]
end = Foo
(* becomes... *)
module rec Foo : sig
type t = string [@@deriving show]
end = struct
type t = string [@@deriving show]
end
(* which becomes... *)
module rec Foo : sig
type t = string
val show: t -> string
end = struct
type t = string
let show t = (* show stuff *)
endUsage
Just use module%gen rec instead of module rec:
module%gen rec Foo : sig
type t = string [@@deriving show]
end = FooLicense
ocaml-ppx_gen_rec is MIT licensed, as found in the LICENSE file.
Dev Dependencies (1)
-
ppx_deriving
with-test
Optional Dependencies
None
Used by (1)
Conflicts
None
Build status
Results of building ppx_gen_rec with each compiler on check.ci.ocaml.org, run of against opam-repository 7cdc698. All results for this package.
Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.
| Version | OCaml 4.11 | OCaml 4.14 | OCaml 5.2 | OCaml 5.4 | OCaml 5.5 |
|---|---|---|---|---|---|
| 2.0.0 (this version) | good | good | good | good | good |
- good Package successfully built
- partial One of the dependencies failed to build
- bad Package failed to build
- n/a Package is not available in this environment
- internal Internal failure