Hello Here is the latest OCaml Weekly News, for the week of February 15 to 22, 2022. Table of Contents ───────────────── OCAML goes Quantum computing Layout Parsing and Nicely Formatted Error Messages ptime 1.0.0 and mtime 1.4.0 Timedesc 0.6.0 OCaml from the Very Beginning now free in PDF and HTML formats Dune 3.0.0 Blog Post "2021 at OCamlPro" Packstream 0.1 OCaml 4.14.0, first beta release Old CWN OCAML goes Quantum computing ════════════════════════════ Archive: Florian said ──────────── It seems that silently OCAML is now entering the Quantum world. It looks that the Interpreter for "Twist" [New programming language for Quantum computing] is made with OCAML: [GitHub for Twist] [New programming language for Quantum computing] [GitHub for Twist] Anton Kochkov then added ──────────────────────── Haskell has a nice package for quantum computing - Quipper. I recommend to take a look to it for inspiration as well: • (a new language that reuses linear types in the Haskell to represent quantum specifics during the Quipper type check) Layout Parsing and Nicely Formatted Error Messages ══════════════════════════════════════════════════ Archive: Hbr announced ───────────── In a previous [post] I have described my way from LALR parsing to combinator parsing. Now I am more and more convinced that combinator parsing is really a good and flexible way to write parsers. The new release 0.5.0 of `Fmlib` focuses on layout parsing and nicely formatted error messages by using combinator parsing. The library can be installed via opam by `opam install fmlib'. There is a [github repository] hosting the source code. The [API] can be found online. See also a [tutorial] on combinator parsing. [post] [github repository] [API] [tutorial] Layout Parsing ╌╌╌╌╌╌╌╌╌╌╌╌╌╌ Most programming languages express hierarchical structures by some kind of parentheses. Algol like languages use `begin' `end', C like languages use curly braces `{', `}' to enclose blocks of code. Since blocks can be nested inside blocks, the hierarchical or tree structure is well expressed by the syntax. For the human reader blocks are usually indented to make the hierarchical structure graphically visible. Programming languages like *Haskell* and *Python* ommit the parentheses and express the hierarchical structure by indentation. I.e. the indentation is part of the grammar. This is pleasing to the eye, because many parentheses can be ommitted. The hierarchical structure in the following schematical source file is immediately visible without the need of parentheses. ┌──── │ xxxxxxxxxxx │ xxx │ xxx │ xxxxxxx │ xxxxxxxx │ xxx └──── Lower level blocks are indented with respect to their parent block and siblings at the same level are vertically aligned. Because of this good readability configuration languages like yaml have become very popular. Unfortunately there are not many parsers available which support indentation sensitivity. The library [Fmlib] has support to parse languages whose grammar uses indentation to structure blocks hierarchically. There are only 3 combinators needed to introduce layout parsing in combinator parsing. Suppose that `p' is a combinator parsing a certain contruct. Then we have • `indent 4 p': Parse the construct described by `p' indented at least 4 columns relative to its environment • `align p': Parse the construct desribed by `p' aligned vertically with its siblings • `detach p': Parse the construct described by `p' without any indentation or alignment restrictions In order to parse a list of ~p~s vertically aligned and indented relative to its environment by at least one column we just write ┌──── │ one_or_more (align p) |> indent 1 └──── and parse a structure with the schematic layout ┌──── │ xxxxxxxx │ │ pppppppp │ │ pppppp │ │ pppp │ │ xxxxx └──── [Fmlib] User Frienly Error Messages ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ It is important to for a parser writer to make syntax error messages user friendly. [Fmlib] has some support to write friendly error messages. There is the operator `' copied from the Haskell library `parsec' which helps to equip combinators with descriptive error message in case they fail to parse the construct successfully. At the end of a failed parsing, the syntax (or semantic) errors have to be presented to the user. Suppose there is a combinator parser for a yaml like structure. The library writes by default for you error messages in the form ┌──── │ 1 | │ 2 | names: │ 3 | - Alice │ 3 | - Bob │ 4 | │ 5 | category: encryption │ ^ │ │ I have encountered something unexpected. I was │ expecting one of │ │ - at 3 columns after │ │ - sequence element: "- " │ │ - at 2 columns before │ │ - key value pair: ": " │ │ - end of input └──── The raw information (line and column numbers, individual expectations, failed indentation or alignment expectation) is available as well so that you can present the error messages to the user in any different form. There is also a component [Fmlib_pretty] in the library for pretty printing any ascii text. [Fmlib] [Fmlib_pretty] ptime 1.0.0 and mtime 1.4.0 ═══════════════════════════ Archive: Daniel Bünzli announced ─────────────────────── It's my pleasure to announce new releases of ptime and mtime. Ptime and mtime provide types and clocks for POSIX and monotonic time. These releases change the JavaScript support strategy for clocks by implementing the primitives in pure JavaScript and linking them via `js_of_ocaml'. This means that both the `ptime.clock.jsoo' and `mtime.clock.jsoo' libraries no longer exist[^1]. Instead simply use the `ptime.clock.os' or `mtime.clock.os' libraries like you would do for your regular programs. By side effect, the packages also no longer depend on any of `js_of_ocaml''s packages. Thanks to Hugo Heuzard (@hhugo) for suggesting and implementing these changes. Thanks also to Jonah Beckford for his Windows build patches. Other changes are described in the release notes for [`ptime'] and [`mtime']. Home pages: [ptime], [mtime] Docs & manuals: [ptime], [mtime] or `odig doc ptime mtime' Install: `opam install ptime mtime' [^1]: I had intended to only deprecate these libraries by `warning' in the `META' files and requiring the replacement library but it seems the warning won't show up in many contexts including `dune' builds. So a breaking change it is. [`ptime'] [`mtime'] [ptime] [mtime] [ptime] [mtime] Timedesc 0.6.0 ══════════════ Archive: Darren announced ──────────────── I am pleased to announce the release of [Timedesc] 0.6.0. Timedesc is a very comprehensive date time handling library with good support of time zone. [Timedesc] Features: ╌╌╌╌╌╌╌╌╌ • Timestamp and date time handling with platform independent time zone support • Subset of the IANA time zone database is built into this library • Supports Gregorian calendar date, ISO week date, and ISO ordinal date • Supports nanosecond precision • ISO8601 parsing and RFC3339 printing Changes ╌╌╌╌╌╌╌ This release adds a fair number of quality of life improvements and additional features. Many thanks to @glennsl for the suggestions and feedback! The most important sections of the changelog are as follows: • Main breaking changes: • Changes in ISO week date functions (shorting label for arguments, quality of life changes) • Removed `_date' suffix in names of `Date.Ymd_date' and `Date.ISO_ord_date' • Added "partial date" modules with ISO8601 parsing and printing facilities • `ISO_week' • `Ym' • Added additional ISO8601 printing facilities for all three calendar systems • `Date.Ymd.pp/to_iso8601' (these are just aliases to the RFC3339 printers) • `Date.ISO_week_date.pp/to_iso8601' • `Date.ISO_ord.pp/to_iso8601' • Added additional ISO8601 parsing facilities for all three calendar systems • `Date.Ymd.of_iso8601[_exn]' • `Date.ISO_week_date.of_iso8601[_exn]' • `Date.ISO_ord.of_iso8601[_exn]' • Added additional comparison functions to `Date' • `lt', `le', `gt', `ge', `compare' • Added arithemtic functions to `Date' • Added `pp/to_iso8601' functions as aliases to the rfc3339 functions to `Timedesc' • Patched ISO8601 parsers and RFC3339/ISO8601 printers to handle second level time zone offset • Rare occurrence in tzdb but picked up by some new tests OCaml from the Very Beginning now free in PDF and HTML formats ══════════════════════════════════════════════════════════════ Archive: John Whitington announced ───────────────────────── Thanks to a grant from the [OCaml Software Foundation], I am able to release my book [OCaml from the Very Beginning] at no cost in its existing PDF format, and in a new HTML format too. You can find it here: [https://johnwhitington.net/ocamlfromtheverybeginning/]. The paperback and Kindle versions continue to be available from Amazon as before. The book has recently been updated to make it ready for OCaml 4.14 which involved only minor changes to error handling and warnings. I have also opened the [source]. [OCaml Software Foundation] [OCaml from the Very Beginning] [https://johnwhitington.net/ocamlfromtheverybeginning/] [source] Dune 3.0.0 ══════════ Archive: Rudi Grinberg announced ─────────────────────── On behalf of the dune team, I’m delighted to announce the availability of dune 3.0. The team has been working on this release for over 6 months, and there’s a bunch of new work to report. I’ll only highlight the some of the interesting new developments: • The watch mode has been rewritten from scratch to be faster and more scalable. We also no longer rely on any 3rd party tools such as fswatch. If any of you still have a dune workspace dune is still struggling with, we cannot wait to hear from you. • The watch mode now also starts an RPC server in the background. This RPC protocol is going to be the basis for other tools to interact with dune. Watch out for announcement on the LSP side to see how we’ll be making use of it to improve the editing experience. • The dune cache has been rewritten as well. It is now simpler and more reliable. There are still some components missing, such as distribution of the artifacts on the network. Nevertheless, we welcome you all to experiment with this feature and give us feedback. • We’ve addressed one of our oldest feature requests: high level rules for ctypes projects. This feature is still experimental, so we need feedback from real world projects before declaring it as mature. Of course, there are many other fixes, enhancements, and only a few breaking changes in this release. We hope you have an easy time upgrading. Happy Hacking. /Editor’s note: for the full changelog, please follow the archive link above./ Blog Post "2021 at OCamlPro" ════════════════════════════ Archive: Fabrice Le Fessant announced ──────────────────────────── We just published a review of what OCamlPro did in 2021: A lot of OCaml, but also some Rust, Cobol, Solidity, and a lot of Formal Verification! OCamlPro is always looking for skilled OCaml developers to hire, so if you are interested, contact us at contact@ocamlpro.com Packstream 0.1 ══════════════ Archive: Tomasz Barański announced ───────────────────────── I have a pleasure to announce the release of [Packstream] 0.1. Packstream is a library to parse/serialize [Packstream binary format]. This is the initial release. It is functional but very very limited in scope. It allows parsing a binary stream into a Packstream datatype and serializing the datatype into a binary stream. [Packstream] [Packstream binary format] OCaml 4.14.0, first beta release ════════════════════════════════ Archive: octachron announced ─────────────────── The release of OCaml 4.14.0 is close. The set of new features has been stabilized, and most opam packages already work with this release. After two alpha releases, we have created a first beta version to help you update your softwares and libraries ahead of the release. If you find any bugs, please report them at: The full release of OCaml 4.14.0 is currently expected for the middle of March. Compared to the last alpha, we have a last minute correction for one of the new function in the Seq module, some documentation improvements, few configuration and internal tweaks. Installation instructions ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ The base compiler can be installed as an opam switch with the following commands ┌──── │ opam update │ opam switch create 4.14.0~beta1 --repositories=default,beta=git+https://github.com/ocaml/ocaml-beta-repository.git └──── With opam 2.1, the previous command line can be simplified to ┌──── │ opam update │ opam switch create 4.14.0~beta1 └──── If you want to tweak the configuration of the compiler, you can switch to the option variant with: ┌──── │ opam update │ opam switch create --packages=ocaml-variants.4.14.0~beta1+options, │ --repositories=default,beta=git+https://github.com/ocaml/ocaml-beta-repository.git └──── or with opam 2.1: ┌──── │ opam update │ opam switch create ocaml-variants.4.14.0~beta1+options └──── where `' is a comma separated list of `ocaml-option-*' packages. For instance, for a flambda and no-flat-float-array switch: ┌──── │ opam switch create 4.14.0~beta1+flambda+nffa ocaml-variants.4.14.0~beta1+options ocaml-option-flambda │ ocaml-option-no-flat-float-array └──── All available options can be listed with `opam search ocaml-option'. The source code for the beta is also available at these addresses: • Changes compared to the last alpha ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ The full list of changes for OCaml 4.14 is available at Standard library ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ • *additional fixes* [10583], +[10998]: Add over 40 new functions in Seq. (François Pottier and Simon Cruanes, review by Nicolás Ojeda Bär, Daniel Bünzli, Naëla Courant, Craig Ferguson, Wiktor Kuchta, Xavier Leroy, Guillaume Munch-Maccagnoni, Raphaël Proust, Gabriel Scherer and Thierry Martinez) [10583] [10998] Documentation ┄┄┄┄┄┄┄┄┄┄┄┄┄ • [10397]: Document exceptions raised by Unix module functions on Windows (Martin Jambon, review by Daniel Bünzli, David Alsopp, Damien Doligez, Xavier Leroy, and Florian Angeletti) • [10794]: Clarify warning 57 (Ambiguous or-pattern variables under guard) (Wiktor Kuchta, review by Gabriel Scherer) [10397] [10794] Build system ┄┄┄┄┄┄┄┄┄┄┄┄ • [10828] Build native-code compilers on OpenBSD/aarch64 (Christopher Zimmermann) • [10835] Disable DT_TEXTREL warnings on x86 32 bit architecture by passing -Wl,-z,notext in mksharedlib and mkmaindll. Fixes relocation issues, reported in [9800], making local patches in Debian, Alpine, and FreeBSD superfluous. (Hannes Mehnert with Kate Deplaix and Stéphane Glondu, review by Xavier Leroy) [10828] [10835] [9800] Code generation ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ • [10719]: Ensure that build_apply respects Lambda.max_arity (Stephen Dolan, review by Xavier Leroy) [10719] Internal/compiler-libs ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ • *additional fixes* [10718], +[11012]: Add "Shape" information to the cmt files. Shapes are an abstraction of modules that can be used by external tooling to perform definition-aware operations. (Ulysse Gérard, Thomas Refis and Leo White, review by Florian Angeletti) [10718] [11012] 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]. [Alan Schmitt] [send me a message] [the archive] [RSS feed of the archives] [online] [Alan Schmitt]