Skip to content

Instantly share code, notes, and snippets.

@shubhamkumar13
Last active March 22, 2024 07:25
Show Gist options
  • Save shubhamkumar13/e4cb71136a9c930e0cde529a3fe75767 to your computer and use it in GitHub Desktop.
Save shubhamkumar13/e4cb71136a9c930e0cde529a3fe75767 to your computer and use it in GitHub Desktop.
what I did in ocaml retreat

Motive

From the Hackacamel list I picked up working on the cdf plotter using TUI. Now I have never developed TUIs or GUIs so I thought this would be the perfect thing to do.

The initial hurdle was choosing the library, I wanted to try use OCaml 5 so I chose Minttea which is TUI framework inspired by Bubble Tea implemented in Golang and uses the The elm architecture (The TEA in minttea).

Biggest Hurdles

Learning Minttea, Esy and Fmt

Since Minttea is a nascent framework I knew it would be a little difficut to learn but the examples provided helped me get to a working mvp quickly although I added some of my own hurdles just to learn stuff. This was not my motive but I like shock therapy.

And I have tinkering with esy for a while and I thought let's try and build a esy-dune workflow to build my projects.

And it was simple to build and play with things. I realised I don't need to have a .merlin file if I am using dune. Dune has a nice way of getting the LSP up and running even with esy. One only needs to specify the dependencies and dev dependencies : Tools that one plans to use like ocaml-lsp-server, ocamlformat etc.

And one more thing : just use esy prefix to build stuff like : esy dune build ./bin/main.exe to build and esy dune exec ./bin/main.exe

I was also scared with the Fmt library I have never been able to use the Format library because a lot of things don't make sense and I think this blurb wouldn't be enough for explaining that but I realised Fmt is a nice way to use Format because there are ways to sanity check using Fmt.Dump.<data-structure>. Later I got to know about pp pretty printer. Which is something that I didn't know and I am thankful for Thibbaut for that.

Was I able to achieve my goal?

Nope, it was hard for me to get a dot printed on the first day because I realised a lot of special characters weren't supported in my outdated version of alacritty.

And then the second day I was able to get the cartesian axis but I couldn't go further in day 3 and day 4.

Mostly because I was kind of having a hard time able to resize the axis for different sizes of terminals and also is there a better way to do it.

What does it look like now

This the repo is here. But I think even it looks like nothing (because it is nothing) I am happy that I started working on this.

What next

Well for one, if you clone this repo there are things that might not work because I am trying to parse the output olly generates. My plan is to get the repo useful for plotting multiple benchmarks on TUI.

And I am seriously considering working on more GUIs and TUIs because it was fun.

I am hoping to it finish this weekend. At least plotting a static graph. Resizing seems like a non-trivial problem but I am sure the TUI communities might have solved it.

Thanks

I want to thank KC, Sudha and Ganesh for organizing OCamlretreat, it was a blast I wish to come again next time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment