[Caml-list] Attn: Development Editor, Latest OCaml Weekly News

Alan Schmitt
2024-05-21T13:07:26Z

[-- Attachment #1: Type: text/plain, Size: 21190 bytes --]

Hello

Here is the latest OCaml Weekly News, for the week of May 14 to 21,
2024.

Table of Contents
─────────────────

We Want Your Feedback on the odoc Developer Experience
Windows compiler support in opam 2.2.0~beta2
OCaml Workshop 2024 at ICFP – announcement and call for proposals
Odoc syntax cheatsheet
DkCoder 0.2 - Scripting in OCaml
Imandra SysML Transpiler Internship Opportunity!
Bam - A property-based testing with internal shrinking
Stitch - Note Managing for Unorganized Minimalists
7 OCaml Gotchas
Using OCaml on windows with WSL
Other OCaml News
Old CWN

We Want Your Feedback on the odoc Developer Experience
══════════════════════════════════════════════════════

Archive:
<https://discuss.ocaml.org/t/we-want-your-feedback-on-the-odoc-developer-experience/14646/1>

Sabine Schmaltz announced
─────────────────────────

Hey all, 🧡🐫

the documentation team at [Tarides] is looking for input and feedback
on odoc.

I would be super happy if everyone who uses odoc or would use odoc if
it worked for them can drop an answer in this feedback form:

<https://docs.google.com/forms/d/e/1FAIpQLSfpZHlnbQjWolAhKJvn41aT5QJc7Gb7uZJSdtTT7MZeAdyMow/viewform?usp=sf_link>

[Tarides] <https://tarides.com>

Windows compiler support in opam 2.2.0~beta2
════════════════════════════════════════════

Archive:
<https://discuss.ocaml.org/t/windows-compiler-support-in-opam-2-2-0-beta2/14648/1>

David Allsopp announced
───────────────────────

On behalf of the entire opam team, but also with a personal sense of
relief, I'm very pleased to announce that the process of upstreaming
support for Windows OCaml to opam-repository in
[ocaml/opam-repository#25861] finally started on Friday!

There's a full [blog post] with details on how you can try this out
now with opam 2.2.0~beta2. The TL;DR, assuming you have winget on your
Windows system (open the Microsoft Store app and install the [App
Installer] package from Microsoft if you don't) then you can issue:

┌────
│ winget install Git.Git
└────

if you don't have Git for Windows and:

┌────
│ winget install opam
└────

if you don't yet have the 2.2.0~beta2 binary. *You must then launch a
fresh Command Prompt / PowerShell session*. For there, you can then
run:

┌────
│ opam init git+https://github.com/dra27/opam-repository.git#windows-initial
└────

or

┌────
│ opam init -a --no-git-location --cygwin-internal-install git+https://github.com/dra27/opam-repository.git#windows-initial
└────

if you'd like to be asked fewer questions. *There is a known and big
pause when updating the repository*. However, after a little bit of
time (coffee, or [a sword battle], if that's your thing), you should
then be faced with a fully initialised opam with
ocaml-base-compiler.5.2.0 installed for the mingw-w64 amd64 port of
native Windows opam.

Things with depexts will likely not work: the blog post contains
details on how to get started with PRs, but issues are also helpful.

The blog post covers what we regard as the "default use case" - that
is a native Windows user expecting to use this new OCaml thing they
heard about natively. i.e. not running in WSL or Cygwin or MSYS2 or
any other "are you sure can't just install Linux on that?" approach.

However, all the other use cases matter too! You're meant to be able
to run native Windows opam from your own Cygwin or MSYS2 mintty bash
terminal; we are aiming for the opam 2.2.0 binary to be a drop-in
replacement (apart from setting `os-distribution' to `"cygwinports"')
for "OCaml for Windows" for legacy use with [the "sunset" repository];
you're meant to be able to provide your own Cygwin or MSYS2
installation if you really need to (and you really might!). But we do
need help testing all of it 🙂

We anticipate one further beta of opam 2.2.0 by the end of the
month. From the Windows perspective, this will fix a known bug in the
environment variable handling (see [ocaml/opam#5838]) but will also
hopefully straighten out the behaviour of `opam init' for some of
these "non-default" use cases. We're then hoping to rocket towards a
release candidate in June 🚀

Happy Windows hacking! Please open issues; please ask for further
help; please have fun!

David, on behalf of the opam team.

[ocaml/opam-repository#25861]
<https://github.com/ocaml/opam-repository/pull/25861>

[blog post] <https://opam.ocaml.org/blog/opam-2-2-0-windows/>

[App Installer] <https://apps.microsoft.com/detail/9nblggh4nns1>

[a sword battle] <https://xkcd.com/303/>

[the "sunset" repository]
<https://github.com/ocaml-opam/opam-repository-mingw>

[ocaml/opam#5838] <https://github.com/ocaml/opam/issues/5838>

OCaml Workshop 2024 at ICFP – announcement and call for proposals
═════════════════════════════════════════════════════════════════

Archive:
<https://discuss.ocaml.org/t/ocaml-workshop-2024-at-icfp-announcement-and-call-for-proposals/14371/6>

Continuing this thread, Sonja Heinze said
─────────────────────────────────────────

One more update, this time about hybrid modalities: We now have the
confirmation from sigplan (the organizers behind ICFP) that we'll have
the same hybrid modalities as last year :tada: So in particular,
speakers can give talks remotely via a Zoom call. We'll also make sure
this time that the remote speaker can see the audience over the
call. To promote a good atmosphere, communication and engagement, we
do prefer to have most talks in-person, but remote talks will be most
welcome as well. So, don't hesitate to submit a talk even if you can't
make it in person.

Cheers, @Armaël and @pitag

PD: Once the time comes closer, we'll give detail on youtube live and
discord links for remote attendance as well

Guillaume Munch-Maccagnoni then added
─────────────────────────────────────

Thanks, this update about hybridity should also be true for the ML
workshop.

Odoc syntax cheatsheet
══════════════════════

Archive:
<https://discuss.ocaml.org/t/ann-odoc-syntax-cheatsheet/14658/1>

Paul-Elliot announced
─────────────────────

Hello!

I'm happy to announce the addition of a [cheatsheet] for odoc's
syntax!

I hope it will make it less painful to learn or refresh yourself on
the topic. The [full syntax reference] is still useful to have some
details.

Have {b fun} :slight_smile: !

[cheatsheet] <https://ocaml.github.io/odoc/cheatsheet.html>

[full syntax reference]
<https://ocaml.github.io/odoc/odoc_for_authors.html>

DkCoder 0.2 - Scripting in OCaml
════════════════════════════════

Archive:
<https://discuss.ocaml.org/t/dkcoder-0-2-scripting-in-ocaml/14560/2>

jbeckford announced
───────────────────

The 0.3 version is now available. It has a publicly accessible
<https://github.com/diskuv/dkcoder> so issues can be filed, and
`cohttp 6.0.0~beta2' is now bundled.

Most important, 0.3 was sufficient to build the real production
service
<https://gitlab.com/diskuv/samples/devops/DkSubscribeWebhook>. It has
a Dockerfile and Docker Compose for easy deployment to production, and
the Docker container is based on Google's
<https://github.com/GoogleContainerTools/distroless#readme> for a
"small" size (well, 100MB is not small but it is not big either). The
only executable in the container is `ocamlrunx' (no `/bin/sh',
etc.). In an ideal world where I had more time the service would be
embedded inside MirageOS instead.

Imandra SysML Transpiler Internship Opportunity!
════════════════════════════════════════════════

Archive:
<https://discuss.ocaml.org/t/imandra-sysml-transpiler-internship-opportunity/14660/1>

Ben Bellick announced
─────────────────────

I wanted to share an opportunity for a summer internship with Imandra!

If you're someone with an interest in writing production OCaml or
using a battle-worn automated theorem prover in an industry setting,
please apply!

It is based in Austin, TX.

You can find more details and apply [here].

Thanks!

[here] <https://apply.workable.com/imandra/j/15392A4445/>

Bam - A property-based testing with internal shrinking
══════════════════════════════════════════════════════

Archive:
<https://discuss.ocaml.org/t/ann-bam-a-property-based-testing-with-internal-shrinking/14661/1>

François Thiré announced
────────────────────────

I am excited to introduce *Bam*, a robust and versatile property-based
testing (PBT) library. Bam simplifies the process of testing
properties across a wide range of randomly generated values, making it
easier to identify and debug issues in your code.

Key Features
╌╌╌╌╌╌╌╌╌╌╌╌

• *Monad-like Generators*: Create new generators easily with a
monad-like pattern that works seamlessly with shrinking mechanisms.
• *PPX Support*: Automatically derive generators based on type
descriptions. The customizable deriver ensures smooth integration
into your codebase.
• *Tezt Integration*: Integrates with the Tezt test framework,
providing a user-friendly experience, especially notable in
debugging scenarios.
• *Internal Shrinking*: Various default shrinking strategies help
efficiently pinpoint minimal counterexamples. Internal shrinking
ensures that only 'smaller' values are used during the process, and
this is done in a way that is compatible with the monad-like
operators.
• *Custom Shrinking*: Define custom shrinkers that work well with the
existing shrinking strategies.

Installation
╌╌╌╌╌╌╌╌╌╌╌╌

You can install Bam using opam:

┌────
│ opam install bam tezt-bam
└────

Getting started
╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌

Here is an example to get you started:

┌────
│ open Tezt_bam
│
│ type t = Foo of {a: int; b: string} | Bar of int list [@@deriving gen]
│ (** The deriver creates a value [val gen : t Bam.Std.t]. *)
│
│ let register () =
│ let property = function
│ | Foo {a; b} ->
│ if a > 1_000 && String.contains b 'z' then
│ Error (`Fail "A counter-example was found")
│ else Ok ()
│ | Bar [1; 2; 3; 4] ->
│ Error `Bad_value
│ | Bar _ ->
│ Ok ()
│ in
│ Pbt.register ~__FILE__ ~title:"Simple example of bam" ~tags:["bam"; "simple"]
│ ~gen ~property ()
│
│ let _ =
│ register ();
│ Test.run ()
└────

There are several more detailed [examples] in the repository to show
you around the library.

[examples] <https://github.com/francoisthire/bam/tree/master/example>

Contributions
╌╌╌╌╌╌╌╌╌╌╌╌╌

Contributions from the community are welcome! If you have ideas, bug
reports, or improvements, feel free to share them!

Kakadu asked and François Thiré replied
───────────────────────────────────────

Can it be compared to <https://github.com/c-cube/qcheck/>
?

My work around /Bam/ started after using "QCheck" and especially
"QCheck2" quite a lot for the Tezos project.

With respect to QCheck, QCheck2 came with "integrated" shrinking
allowing to derive automatically shrinkers for generators. This aim to
simplify debugging when a counter-example is found, so that a smaller
example is reported to the user.

However, this came with a cost:
• Performance-wise, there was a regression from "QCheck", especially
the time taken to report a counter-example because the shrinking
process was taking a lot of time
• At some point, we even faced an issue were the shrinking process
never ended. We started to implement an ad-hoc shrinker but it was
not working either and we never really figured out. The solution was
to deactivate shrinking
• There are other UX considerations: debugging can be tedious
(especially "hello" debugging)

So basically /Bam/ started as an experiment to understand shrinking
and come up with something easier to understand and compose
better. This is why /bam/ relies mainly on monadic operators.

This makes the writing of generators easier, the shrinking is
/internal/ ensuring the shrinking won't create new value. If you use
the mondic operator of QCheck2, last time I checked it was not the
case. This is why to create a generator for a pair, it is recommended
to use `tup2' instead of monadic operators.

Using monadic-operators allows you also to have a smaller kernel that
is hopefully easier to maintain.

I also developped the integration of /bam/ with Tezt in a way to avoid
currently pitfalls we had with `QCheck2':
• You can easily control the stopping condition of the test
• The test can be easily run in parallel or in a loop mode to help you
find a counter-example quicker
• The runner can fail if not enough values were generated or execution
was too long (likely due to a regression)
• It captures the output, so that only the one for the counter-example
printed is shown. This is very handy during debugging. Otherwise, it
is quite tedious to understand which line comes from which attempt
• It is easy to opt-out from shrinking if it takes too much time. Can
be useful for a CI. Shrinking only needs to be executed locally
(assuming the property is deterministic) with a given seed

I also had some fun trying to define shrinking strategies allowing you
to skip elements in a list. This is very handy when your property is
about running a scenario made of a list of actions (a use-case very
close to the monolith library from François Pottier). In general the
initial counter-example contains superfluous actions. Such a strategy
allows you to remove them to easy the debugging.

I don't have concrete data to compare Bam with QCheck2 at the
moment. Let me know if you have ideas to make an objective comparison
between those two libraries.

Stitch - Note Managing for Unorganized Minimalists
══════════════════════════════════════════════════

Archive:
<https://discuss.ocaml.org/t/stitch-note-managing-for-unorganized-minimalists/14664/1>

Marc Coquand announced
──────────────────────

Hey everyone!

I wanted to share a cli tool built in OCaml I've been working on, that
was only possible with the help of the community. :slight_smile:

The tool is called stitch, and is a minimal note-managing tool that
aims to be a good unix citizen. It allows you to take notes in
whatever format/editor you want while spending minimal time organizing
them.

I built it using Cmdliner, Notty and Shexp. I'm drafting a longer
writeup to share the challenges and general experience, but in short
all three libraries were a bit short on examples but ultimately
excellent and very easy to work with. Afterward, packaging everything
turned out to be a bit harder.

Some screenshots: [overview], [todo], [full-notes].

And link to repo:

<https://git.mccd.space/pub/stitch/about/>

It's still in it's early days and the code-base is a bit messy. But I
use it as my daily driver for notes. :slight_smile:

[overview] <https://blobs.mccd.space/stitch/notes-view.png>

[todo] <https://blobs.mccd.space/stitch/todo-view.png>

[full-notes] <https://blobs.mccd.space/stitch/full-notes-view.png>

7 OCaml Gotchas
═══════════════

Archive: <https://discuss.ocaml.org/t/blog-7-ocaml-gotchas/14667/1>

Dmitrii Kovanikov announced
───────────────────────────

Hi everyone! :wave:

I've been using OCaml for a while, and I'm quite enjoying the
language. In my not-so-long journey, I discovered a few surprising
OCaml behaviours, so I decided to share them with everyone in a blog
post.

• [7 OCaml Gotchas]

I hope it reduces frustration for newcomers when they see something
unexpected for the first time!

[7 OCaml Gotchas] <https://dev.to/chshersh/7-ocaml-gotchas-207e>

Using OCaml on windows with WSL
═══════════════════════════════

Archive:
<https://discuss.ocaml.org/t/blog-using-ocaml-on-windows-with-wsl/14671/1>

PizieDust announced
───────────────────

When I got started in OCaml, my setup was basically a dual boot of
Windows 11 and Ubuntu. I had a few issues setting up OCaml on windows
at the time and started looking up WSL and if it was a good
alternative (I really disliked having to dual boot always). So I wrote
this article detailing exactly how I setup OCaml on WSL and have been
using it for the past 12 months with no issues. So if you are looking
to get started with programming in OCaml on windows, this article is
for you.

[How to setup OCaml on Windows with WSL]

Note: `opam 2.2' makes it a breeze using OCaml on windows natively so
if you are particularly interested about using OCaml without WSL you
should check it out.

[How to setup OCaml on Windows with WSL]
<https://tarides.com/blog/2024-05-08-how-to-setup-ocaml-on-windows-with-wsl/>

Other OCaml News
════════════════

From the ocaml.org blog
───────────────────────

Here are links from many OCaml blogs aggregated at [the ocaml.org
blog].

• [The MirageOS retreat 2024]
• [The OCaml 5.2 Release: Features and Fixes!]
• [Beta release of Frama-C 29.0~beta (Copper)]
• [Bye Opam, Hello Nix]
• [How to Setup OCaml on Windows with WSL]
• [Announcing DBCaml, Silo, Serde Postgres and a new driver for
postgres]
• [Fixing and Optimizing the GnuCOBOL Preprocessor]

[the ocaml.org blog] <https://ocaml.org/blog/>

[The MirageOS retreat 2024]
<https://hannes.robur.coop/Posts/Retreat2024>

[The OCaml 5.2 Release: Features and Fixes!]
<https://tarides.com/blog/2024-05-15-the-ocaml-5-2-release-features-and-fixes>

[Beta release of Frama-C 29.0~beta (Copper)]
<https://frama-c.com/fc-versions/copper.html>

[Bye Opam, Hello Nix]
<https://priver.dev/blog/ocaml/bye-opam-hello-nix/>

[How to Setup OCaml on Windows with WSL]
<https://tarides.com/blog/2024-05-08-how-to-setup-ocaml-on-windows-with-wsl>

[Announcing DBCaml, Silo, Serde Postgres and a new driver for postgres]
<https://priver.dev/blog/dbcaml/dbcaml-project/>

[Fixing and Optimizing the GnuCOBOL Preprocessor]
<https://ocamlpro.com/blog/2024_04_30_fixing_and_optimizing_gnucobol>

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].

[Alan Schmitt]

[send me a message] <mailto:alan.schmitt@polytechnique.org>

[the archive] <https://alan.petitepomme.net/cwn/>

[RSS feed of the archives] <https://alan.petitepomme.net/cwn/cwn.rss>

[caml-list] <https://sympa.inria.fr/sympa/info/caml-list>

[Alan Schmitt] <https://alan.petitepomme.net/>

[-- Attachment #2: Type: text/html, Size: 35295 bytes --]