Showcase: Using Kakoune with awk to generate types in OCaml

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

let my_query =
      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.

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.

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.


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

1 Like

Really cool script and blog ! :blush:

1 Like