- Notifications
You must be signed in to change notification settings - Fork6
ocaml preprocessor that generates a recursive module
License
flow/ocaml-ppx_gen_rec
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A ppx rewriter that transforms arecursive moduleexpression into astruct
.
If you write a recursive module like this:
module rec Foo : sig type t = stringend = Foo
The compiler treats it like you wrote:
module rec Foo : sig type t = stringend = struct type t = stringend
If you try to useppx_deriving
, you get aUndefined_recursive_module
exception, becauseppx_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 -> stringend = struct type t = string let show _ = raise Undefined_recursive_moduleend
Useppx_gen_rec
beforeppx_deriving
to generate an explicit struct, which will causeppx_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 -> stringend = struct type t = string let show t = (* show stuff *)end
Just usemodule%gen rec
instead ofmodule rec
:
module%gen rec Foo : sig type t = string [@@deriving show]end = Foo
ocaml-ppx_gen_rec is MIT licensed, as found in the LICENSE file.
About
ocaml preprocessor that generates a recursive module
Resources
License
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.