# Showcase: Using Kakoune with awk to generate types in OCaml

**URL:** <https://discuss.kakoune.com/t/showcase-using-kakoune-with-awk-to-generate-types-in-ocaml/2419>\
**Category:** Resources\
**Created:** [March 4, 2024, 3:21pm UTC](https://discuss.kakoune.com/t/showcase-using-kakoune-with-awk-to-generate-types-in-ocaml/2419 "2024-03-04T15:21:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcc](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/marcc/32/1464_2.png) [@marcc](https://discuss.kakoune.com/u/marcc)\
**Post date:** [March 4, 2024, 3:21pm UTC](https://discuss.kakoune.com/t/showcase-using-kakoune-with-awk-to-generate-types-in-ocaml/2419/1 "2024-03-04T15:21:02Z")

</div>

Heya everyone!

I wrote a small blog post where I showcase how I use Kakoune together with Awk to generate types for OCaml.

In OCaml, you deal with SQL statements that look like this

```auto
let my_query =
  [%rapper
    get_opt
      {sql|
      SELECT @int{id}, @string{username}, @bool{following}, @string?{bio}
      FROM users
      WHERE username <> %string{wrong_user} AND id > %int{min_id}
      |sql} record_out]

```

Unless you want a tuple as the return type, you need to manually create a record type for the return result.

```auto
type my_query_result = 
 { id : int
 ; username : string
 ; following : bool
 ; bio : string option
 }

```

I found this tedious, so I wrote an awk script to do it for me and called it from within Kakoune. The final workflow in the end looks like [this](https://asciinema.org/a/644993).

I thought it was a cool demonstration for just how easy Kakoune is to extend and wanted to share with you guys :).

If you’d like the full script, you can find it in the blog post [here](https://mccd.space/posts/awk-with-kakoune/).

---

<div class="post-metadata">

**Author:** ![possumvibes](https://discuss.kakoune.com/letter_avatar_proxy/v4/letter/p/ea666f/32.png) [@possumvibes](https://discuss.kakoune.com/u/possumvibes)\
**Post date:** [March 4, 2024, 8:27pm UTC](https://discuss.kakoune.com/t/showcase-using-kakoune-with-awk-to-generate-types-in-ocaml/2419/2 "2024-03-04T20:27:46Z")

</div>

Neat post, thanks for sharing it! I’ve been meaning to learn about Awk and this gives me a great springboard.

---

<div class="post-metadata">

**Author:** ![Nasmekva](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/nasmekva/32/1238_2.png) [@Nasmekva](https://discuss.kakoune.com/u/Nasmekva)\
**Post date:** [March 14, 2024, 1:23pm UTC](https://discuss.kakoune.com/t/showcase-using-kakoune-with-awk-to-generate-types-in-ocaml/2419/3 "2024-03-14T13:23:03Z")

</div>

Really cool script and blog ! 😊
