OCaml Weekly News

Previous Week Up Next Week

Hello

Here is the latest OCaml Weekly News, for the week of December 19 to 26, 2023.

Table of Contents

Release of odoc 2.4.0

Emile Trotignon announced

The odoc team is delighted to announce the release of odoc 2.4.0. It mainly contains support for search engines. There are of course bugfixes and smaller new features.

:star2: Spotlight Feature of Odoc 2.4.0 : Search

Odoc now support searching in the documentation ! The search is made to run in the browser, so that you do not need a server to enable search: you can have search on your documentation hosted on github pages or even locally on your machine.

No search engine is shipped with, you need to provide one, but all the facilities to make use of one are present. We adapted @art-w ’s sherlodoc for seamless integration with odoc, alongside with new features. It is not yet released on opam, but we hope it will be soon.

You can already test sherlodoc and play with it on your own projects, there are instructions in its readme. Sherlodoc has fuzzy typed-based search like hoogle in the haskell world, and is made to work best for OCaml (unlike a general purpose search engine like elastic search).

Check the results on odoc’s own online documentation : ocaml.github.io/odoc.

:handshake: Join The Mission

While we are dedicated to developing the best tooling to generate and serve documentation on OCaml.org, creating a well-documented library ecosystem can only be a collective effort. Package authors: we’re working hard to give you great tools, but we’ll need all your help to create an ecosystem of well-documented libraries for OCaml!

If you find that writing documentation for your library isn’t as straightforward as you would like, please do share your feedback with us.

:gear: Full changelog

  • Added
    • Add support for external search engines (@panglesd, @EmileTrotignon, #972) This includes the generation of an index and the display of the results in the UI (HTML only).
    • Display ’private’ keyword for private type extensions (@gpetiot, #1019)
    • Allow to omit parent type in constructor reference (@panglesd, @EmileTrotignon, #933)
  • Fixed
    • Warn and exit when table(s) is not closed (@lubegasimon, #1050)
    • Hint when list(s) is not closed (@lubegasimon, #1050)
    • Fix crash on functors returning an alias (@Julow, #1046)
    • Fix rendering of polymorphic variants (@wikku, @panglesd, #971)
    • Add references to extension declarations (@gpetiot, @panglesd, #949)
  • Changed
    • Style: Adjusted line height in the TOC to improve readability (@sorawee, #1045)
    • Style: Remove font fallback to Helvetica, Arial (@Julow, #1028)
    • Style: Preformatted elements fallback to UA monospace (@toastal, #967)
    • Style: Sidebar is now stuck to the left of the content instead of the left of the viewport (@EmileTrotignon, #999)

Ppxlib dev meetings

Continuing this thread, Sonja Heinze announced

Here are today’s meeting notes: https://github.com/ocaml-ppx/ppxlib/wiki/Dev-meeting-19-12-2023

>From next meeting on, I’ll make sure to only send one message on discuss per meeting containing both the agenda and a link to future meeting notes.

Have a nice new year everyone! :tada::)

grid 0.1.0 - A tiny library for two-dimensional arrays

Jean Christophe Filliatre announced

Dear all,

My colleague @K_N managed to have half of the lab addicted to Advent of Code :sweat_smile:

This year, many problems involve grids, and it proved useful to have a tiny library to handle two-dimensional arrays. So here it is (and via opam):

Nothing sophisticated, and nothing you could not do with Array from the standard library, of course, but useful nonetheless.

Note: This is not a linear algebra library.

Happy hacking, Jean-Christophe

Draft tutorials on Modules, Functors and Libraries

Cuihtlauac Alvarado announced

Dear OCamlers,

The series on ocaml.org tutorial updates continue. This time, the ocaml.org team has three drafts related to the module system in a single pull request. We want your feedback on it:

The target audience is developers learning OCaml. No functional programming knowledge is assumed. However, it comes after the “Get Started” series:

  1. Installing OCaml
  2. A Tour of OCaml
  3. Your First OCaml Program

They also require the first two tutorials of the “Introduction” series as prerequisites:

  1. Values and Functions
  2. Basic Datatypes and Pattern Matching

As the previously announced drafts, these also contain overlooked issues. We want to make it better with your help.

Share your feedback on GitHub or here, but do not use the “Contribute” link at the bottom of the staging pages.

Hope it helps

Esperanto, when OCaml meets Cosmopolitan

Calascibetta Romain announced

I’m glad to announce the release of Esperanto (0.0.5). This release integrates the last release of Cosmopolitan 3.1.

The latter incorporates a great deal of work on the Cosmopolitan toolchain:

  1. a modification of the GCC compilation so that code no longer needs to be patched to transform constants into variables
  2. cross-compilation support for aarch64
  3. support for Apple Silicon

This release introduces a change in the construction of the portable artifact from OCaml source code, which is explained here. More generally, the steps are:

  • compilation to x86_64
  • compilation to aarch64
  • linking the two artifacts with apelink.

Currently, this version of Esperanto has been tested with bob, an OCaml file-sharing program. We have tested its portability on Debian, Ubuntu, Mac M1, FreeBSD and Windows. As we make clear in the description, Esperanto’s sole purpose is to assist in the distribution of software (rather than to provide a supportive environment for developers). We therefore advise you to use Docker (or related technology) to create your portable executable from your sources (bob has, for example, a GitHub CI that produces such an executable).

Of course, we’re planning to integrate with OCaml 5, since pthread support is now available in Cosmopolitan (it wasn’t at first). So we only support OCaml 4.14 and OCaml 4.13. We’re waiting for a review of another project which is preparing its transition to OCaml 5 (ocaml-solo5) before integrating it into Esperanto.

Finally, we would like to thank the robur.coop cooperative (which you can help) for giving us the freedom to maintain this project.

PS: Esperanto is still in [a release process]() (and not immediately available via OPAM), but the process should be completed in the next few days.

OCaml in cultural heritage

zedstar announced

Hi all!

Just wanted to share some efforts to bring OCaml to the cultural heritage sector. So far I have built a web annotation server using Dream and Irmin https://github.com/nationalarchives/miiify but have some plans to continue the work.

The challenges for our digital services are mainly around scale and there is a growing interest around green computing. Inspired by the talk Hannes gave at CCC, it would be great to explore the benefits of MirageOS!

colors 0.0.1 – colorspace manipulation in pure OCaml

ostera announced

Hi folks :wave: just wanted to share a little library I put together to do color manipulation in Mint Tea. It’ll be used in the next release of Mint Tea, and allow us to do gradients and all sorts of nice color stuff:

56ebee747107d8e9dc9dec79edf7d39b30c98088.gif

543f4fae71143670719e56e7e294e7b138c54ff7.gif

This first release of colors:

  • Introduces RGB, LRGB, XYZ, LUV, UV types
  • Includes standard white reference point `d65`
  • Supports Linearizing/Delinearizing RGB
  • Includes conversions between ANSI, RGB, LRGB, XYZ, and LUV
  • Has blending for LUV and RGB (via LUV) with configurable mixing
  • Includes an ANSI to RGB color table

I’m hoping to keep it super small and in pure OCaml so we can use it for terminals but also other places like web, or other graphics settings.

You can read the full changelog here.

If you’re interested in contributing to any of these, look for open good first issues, and don’t hesitate to reach out on Discord/X: @leostera :slight_smile:

Happy hacking! :camel: :hand_with_index_finger_and_thumb_crossed:

OCaml is awesome

jbeckford announced

I have a full article and repository at https://gitlab.com/diskuv/samples/merrychristmas2023#dksdk-merry-christmas-2023.

Short version … huge thanks to Oleg for his preprint paper Generating C: Heterogeneous metaprogramming system description. I’ve adapted it so it mostly works with PPX and without BER MetaOCaml (although I intend to switch to BER MetaOCaml at some point).

Typing real OCaml on your keyboard:

$ git clone https://gitlab.com/diskuv/samples/merrychristmas2023.git
$ cd merrychristmas2023
$ opam switch create . 4.14.1 # or on Windows: dkml init
$ opam install . utop --with-test --yes
$ opam exec -- dune utop
#require "metaquot.ppx";;
open DkSDKMetatype_Offshore;;
open Xmas2023;;
let sum_ar_staged =
  ( Lexing.dummy_pos,
    [%expr
      fun arr n ->
        let sum = ref 0 in
        for i = 0 to 3 do
          for j = i to min (i + 3) (n - 1) do
            sum := !sum + arr.(j)
          done
        done;
        !sum],
    Lexing.dummy_pos ) ;;

print_c "sum_ar" (module SumArConv) sum_ar_staged ;;

prints real C code:

int DkSDKMetatype_Offshore_sum_ar(int * const arr,int const n){
  int sum = 0;
  for (int i = 0; i < (1 + 3); i += 1)
    for (int j = i; j < (1 + min(i + 3,n - 1)); j += 1)
    sum = sum + (arr[j]);
  return sum;
}

Other languages are easy to add.

Merry Christmas! Jonah

Other OCaml News

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 to the caml-list.