OCaml Weekly News

Previous Week Up Next Week

Hello

Here is the latest OCaml Weekly News, for the week of April 25 to May 02, 2023.

Table of Contents

Lambda Capabilities

Thomas Leonard announced

Several people, after reading the Eio tutorial, have asked for more details about what “capabilities” are (and why they should care). I couldn’t find an introduction aimed at functional programmers, so I had a go at writing my own:

https://roscidus.com/blog/blog/2023/04/26/lambda-capabilities/

Please let me know if anything is unclear!

My Thoughts on OCaml vs Haskell/Rust in 2023

Sid Kshatriya announced

Recently, osa1’s My Thoughts on OCaml generated quite a robust conversation on Hacker News. Overall I felt the blog post was a bit too critical about OCaml. However, everyone has a right to their opinions and I respect whatever has been written.

Except for a couple of points, that post didn’t resonate with me, so I thought I should pen down my good/bad experiences with OCaml and see if others have felt the same way as me.

I’ve written a longish blog post here as sort my reponse! Please check it out!

Your feedback and comments would be useful!

If people think this is a worthy blog post, I’d like to post my blog on Hacker news also :-). If anybody feels enthusiastic about this write up do feel free to put it up on Hackernews yourself too!

Tim McGilchrist later said

Another take on the current state of OCaml from https://borretti.me/article/two-years-ocaml. There are many points I do and don’t agree with from both, but I think it is important to reflect on the language and tooling. These fresh takes on things are useful to read. Thanks @sid for taking the time to write your version up.

For me personally I would like a version of modular implicits to land and to have a typed effect system to go along with my EIO/Multicore. I should writeup a longer version given my background with Haskell and OCaml.

Interesting OCaml Articles

NomadicLabs announced

We published a blog post that might be interesting to OCaml devs. When working with large codebases such as Tezos Octez, it is important to make the code highly readable. Discover “labelled type parameters” - a lesser-known OCaml trick used by Nomadic Labs devs to reach this objective: https://research-development.nomadic-labs.com/labelled-type-parameters-in-ocaml.html

Dream-html - DSL to build HTML, integrated with Dream

Yawar Amin announced

Hi, I have been working on a ’simple’ OCaml library to generate HTML, with close integration with Dream. I am already using it on a side project and think it’s nearing production level for general use. I wanted to give a preview here in case anyone is interested.

In terms of approach taken, it is closer to Webs_html than to TyXML. Things that are statically typechecked:

  • ’Standard’ tags have attributes and children
  • Void elements have no children
  • Some tags can contain only a single text node
  • Attributes with boolean, int, or enumerated string values

All attributes and text nodes support format strings i.e. interpolation. So no need to pull in Printf.sprintf. HTML comments are also supported. HTML escaping is done for almost all text nodes and attribute values, leaving aside the ones that aren’t supported by Dream’s escaping i.e. JavaScript and CSS content.

Oh, one more thing. I also added the core htmx attributes since I’m using htmx.

Check out the test file for a slightly larger idiomatic usage: https://github.com/yawaramin/dream-html/blob/main/test/dream_html_test.ml

Simon Cruanes then said

Very nice! I like this combinator-based approach, I have a similar thing in tiny_httpd. I think it’s a nice balance between simplicity and expressiveness.

Trying the 7GUIs with LablGTK3/OCaml

Frédéric Loyer announced

I have tried to implement the 7GUIs (https://eugenkiss.github.io/7guis/) with LablGTK3/OCaml.

The first 6 are done (but would need some polishing). The last one won’t be possible (there are no real Table widget in Gtk… then the gtksheet example is rather big).

I hhave to admit that finding some functions/method was not always easy. For changing the background of a widget, multiple methods exist and only one works. Some methods are hidden in a #misc suffix (drawing#misc#queue_draw…), I had to hack some way to create a GMisc.drawing_area of a given dimension since this constructor doesn’t like ~width or ~height. But the library seems to be rather convenient and complete.

See Implementation of 7GUIs in OCaml with LablGtk3

Later on, Frédéric Loyer said

I guess the Cells is nearly ready with one function (SUM) which support range and list of range, the 4 arithmetic operators + 2 unary operators. There are some lacking enhancement (NullValues could be seen as 0…).

The number of lines of code is:

   21 lexer.mll
   43 parser.mly
  189 expr.ml
   73 cells.ml
  326 total

The 7th is nearly as big as the 6 first together!

Where all the spreadsheet engine is in expr.ml Cells deals with the GUI (and the Parser calls since I can have a depancy circle Parser<->Expr).

Frédéric Loyer added

Note, the site has migrated here : https://7guis.github.io/7guis/implementations/

I hope my pull request will be handled soon and makes my contribution referenced.

Call for new opam-repository maintainers

Kate announced

Come and help maintenance of the opam-repository!

opam-repository is the official store of package descriptions for the OCaml ecosystem. It allows everyone to easily install whatever dependency their project might need. It also allows everyone, by just opening a PR, to easily make their code available to the community at large.

The repository is maintained by a handful of people who work together to ensure that the packages are up-to-date, high-quality, and their metadata are consistent. We are looking for new contributors to help us maintain the repository and keep it running smoothly.

You don’t need to be an expert in OCaml or opam to get involved – all you need is a willingness to learn and a desire to contribute (and a github account :sweat_smile:). As a new maintainer, you’ll start with triaging access, which means you’ll be able to review and approve changes to the repository. After a few weeks of successful triaging, you can decide to stick around and you’ll be granted full access.

Let us know if you have any questions or if you want to try it out!

Kate, Marcello, Raphaël

Old CWN

If you happen to miss a CWN, you can send me a message and I’ll mail it to you, or go take a look at the archive or the RSS feed of the archives.

If you also wish to receive it every week by mail, you may subscribe online.