# Variant type constructors or currying

**URL:** <https://discuss.ocaml.org/t/variant-type-constructors-or-currying/2183>\
**Category:** Learning\
**Created:** [June 21, 2018, 10:15pm UTC](https://discuss.ocaml.org/t/variant-type-constructors-or-currying/2183 "2018-06-21T22:15:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erik\_Lott](https://avatars.discourse-cdn.com/v4/letter/e/aeb1de/32.png) [@Erik\_Lott](https://discuss.ocaml.org/u/Erik_Lott)\
**Post date:** [June 21, 2018, 10:15pm UTC](https://discuss.ocaml.org/t/variant-type-constructors-or-currying/2183/1 "2018-06-21T22:15:51Z")

</div>

I find myself creating constructors for variant types so that I am able to curry and do partial application:

```
type thing
   = ThingOne of int * int
   | ThingTwo of string

let thing_one v1 v2 = ThingOne (v1, v2)
let thing_two s = ThingTwo s

```

I find this less verbose than using anon functions everywhere…

```
func (v1, v2) -> ThinkOne (v1, v2)

```

We have to do quite a bit of partial application with variants like this in our app. Is there a better way to do this in OCaml, or is this the generally accepted method?

---

<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:** [June 21, 2018, 10:22pm UTC](https://discuss.ocaml.org/t/variant-type-constructors-or-currying/2183/2 "2018-06-21T22:22:37Z")

</div>

You could consider at [ppx\_variants\_conv](https://github.com/janestreet/ppx_variants_conv), which does pretty much what you’re describing AFAICT.

---

<div class="post-metadata">

**Author:** ![Erik\_Lott](https://avatars.discourse-cdn.com/v4/letter/e/aeb1de/32.png) [@Erik\_Lott](https://discuss.ocaml.org/u/Erik_Lott)\
**Post date:** [June 22, 2018, 12:55am UTC](https://discuss.ocaml.org/t/variant-type-constructors-or-currying/2183/3 "2018-06-22T00:55:05Z")

</div>

Thanks, I’ll check that out. This looks like what I need.
