# Ppx for reifying constructors

**URL:** <https://discuss.ocaml.org/t/ppx-for-reifying-constructors/10855>\
**Category:** Ecosystem\
**Tags:** ppx\
**Created:** [November 24, 2022, 6:37pm UTC](https://discuss.ocaml.org/t/ppx-for-reifying-constructors/10855 "2022-11-24T18:37:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nobrowser](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nobrowser/32/2099_2.png) [@nobrowser](https://discuss.ocaml.org/u/nobrowser)\
**Post date:** [November 24, 2022, 6:37pm UTC](https://discuss.ocaml.org/t/ppx-for-reifying-constructors/10855/1 "2022-11-24T18:37:29Z")

</div>

In SML (and similarly Haskell), if I write

```auto
datatype foo = Foo of int

```

I can use `Foo` as a 1st class functional value with type `int -> foo`. In Ocaml this is not so, I have to write something like `(function x -> Foo x)` or give this snippet a name and use that. So my question is, is there a ppx which would generate these trivial functions for me automatically?

---

<div class="post-metadata">

**Author:** ![bcc32](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/bcc32/32/203_2.png) [@bcc32](https://discuss.ocaml.org/u/bcc32)\
**Post date:** [November 24, 2022, 7:43pm UTC](https://discuss.ocaml.org/t/ppx-for-reifying-constructors/10855/2 "2022-11-24T19:43:04Z")

</div>

[GitHub - janestreet/ppx\_variants\_conv: Generation of accessor and iteration functions for ocaml variant types](https://github.com/janestreet/ppx_variants_conv) does this and also generates some other useful values based on variants.

Similarly [GitHub - janestreet/ppx\_fields\_conv: Generation of accessor and iteration functions for ocaml records](https://github.com/janestreet/ppx_fields_conv) for record fields.
