Hello Here is the latest OCaml Weekly News, for the week of November 24 to December 01, 2020. Table of Contents ───────────────── drom.0.2.0: OCaml Project Manager, beta release OCaml on the BEAM webinar ocaml-lsp-server 1.3.0 OCaml User Survey 2020 http-cookie 2.0.0 reparse 2.0.0 VSCode OCaml Platform v1.5.0 Database modelling Opium 0.19.0 Operator lookup tool for OCaml Other OCaml News Old CWN drom.0.2.0: OCaml Project Manager, beta release ═══════════════════════════════════════════════ Archive: Fabrice Le Fessant announced ──────────────────────────── I am happy to announce the first release of `drom', version 0.2.0, a tool to create and manage OCaml projects. `drom' is a simple layer on top of `opam' and `dune', with project and package descriptions written in TOML syntax. It is an attempt at providing a `cargo'-like experience for developers, with builtin support for standard OCaml tools (`opam', `dune', `odoc', etc.) and source managers (Github for now, with Github Actions and Github Pages). There are mainly 2 use-cases of `drom': • Scafolding tool: `drom' makes it easy to create OCaml projects by generating all the files needed for a standard OCaml project. It creates files for `opam' and `dune', formatters (`ocp-index' and `ocamlformat'), documentation (`sphinx' and `odoc'), testing directories and Github CI. Once these files have been created, `drom' is not needed anymore and you can keep using your preferred tools. • Management tool: `drom' can also be used to keep managing the project afterwards. It has commands like `drom build' to build the project, automatically installing a local switch with all needed dependencies, `drom doc' to generate the documentation and `drom test' to execute tests. `drom' works as a simple interface over `opam' and `dune' so you almost never need to use them directly. (this site and the documentation was mostly generated by `drom' itself) `drom' is available in the official opam repository. Examples: ┌──── │ $ drom new mylib --skeleton library // generate library project │ // or │ $ drom new hello // generate program project │ │ $ cd hello │ $ emacs drom.toml // edit the project description │ $ drom project // update files │ $ drom build // create local switch and build │ // or │ $ drom build --switch 4.10.0 // use global switch and build │ $ ./hello // run the executable │ $ drom test // run tests │ $ drom install // install in opam switch └──── This is an early release to get feedback from users. `drom' has been tested on several of our internal projects, like `opam-bin' and `ez_file'. Since `drom' creates local `opam' switches for every project by default (though it is possible to use global switches too), it is advised to use it with `opam-bin' to speed up switch creation and upgrades. `drom' works by creating projects using "skeletons", i.e. project and package templates. `drom' comes with a few predefined skeletons (`program' or `library'), and allows users to add their own skeletons. We will of course extend the substitution language to help users develop such new skeletons. `drom' is a collaborative work between OCamlPro and Origin Labs. François Bobot asked and Fabrice Le Fessant replied ─────────────────────────────────────────────────── I'm very happy to see work in the OCaml world in that direction. I was currently looking for duniverse for that kind of need. Do they fullfil different needs or how do they compare? My understanding is that `duniverse' tackles the problem of the "mono-repo", i.e. when you want to manage many different projects as just one project, using `dune' capacity to build them all at once. I would say that `drom' tackles an orthogonal problem, which is to simplify the creation of simple OCaml projects (generating all the standard files you need, like Makefile, dune-project, dune, .ocamlformat, .github CI, documentation, license, etc.) and day-to-day management (changing dependencies, having a copy of headers that you can insert in new files, etc.). It also provides a single interface over basic opam/dune commands. It would probably be possible to use `duninverse' on a set of projects containing projects generated by `dune', but I don't know enough about `duniverse' to be sure. Of course, `drom' can manage projects composed of multiple libraries and executables (called `packages' because `drom' generates one `opam' file for every one of them), but I wouldn't call that a mono-repo, it's just frequent to have more than one package in a small project. OCaml on the BEAM webinar ═════════════════════════ Archive: Yawar Amin announced ──────────────────── Erlang Solutions is going to do a webinar on Leandro Ostera's new BEAM backend for OCaml: Should be exciting! ocaml-lsp-server 1.3.0 ══════════════════════ Archive: Rudi Grinberg announced ─────────────────────── On behalf of the ocaml-lsp team, I’d like to announce version 1.3.0. This release an improvement in keyword completion and a new code action. Keywords are now filtered by the context the user requested the completion, and there's a new code action to quickly populate .mli files with the the inferred types from the .ml file. OCaml User Survey 2020 ══════════════════════ Archive: Xavier Leroy announced ────────────────────── Here is a summary and analysis of the survey results I wrote on behalf of the OCaml Software Foundation: Enjoy! http-cookie 2.0.0 ═════════════════ Archive: Bikal Lem announced ─────────────────── A new version of `cookies' package - now named `http-cookie'- has been released to opam. This version has been rewritten to remove all its external and ppx dependencies and now only depends on stock ocaml and its stdlib. `http-cookie' is a [RFC 6265] compliant HTTP cookie library. RFC 6265 is a HTTP cookie standard specifying cookie data validity requirements. Additionally, I have also removed the use of `Result.t' from the previous version and have used plain old exceptions to denote any cookie data validation errors. • [Github - http-cookie] • [Docs - http-cookie] [RFC 6265] [Github - http-cookie] [Docs - http-cookie] reparse 2.0.0 ═════════════ Archive: Bikal Lem announced ─────────────────── A new version of `reparse' 2.0.0 has been released to opam. Reparse is a monadic, recursive descent based, comprehensive, parser construction library for ocaml. CHANGES for version 2.0.0: ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ • Rewrite the whole package to use exceptions rather than `result' type • Adds many more parsing combinators • Adds comprehensive unit tests • Adds comprehensive documentation, host documentation and add links in repo home page • Adds abstraction for input source • Provides unix file source and string input source • Adds separate package `reparse-unix' for unix file input • Adds calc.ml and json.ml in examples. Additionally, the API is now comprehensively documented with at least an example for each API call. • [Github Reparse] • [API Docs] [Github Reparse] [API Docs] VSCode OCaml Platform v1.5.0 ════════════════════════════ Archive: Max Lantas announced ──────────────────── We are happy to announce the v1.5.0 release of [VSCode OCaml Platform], a Visual Studio Code extension for OCaml. It is available on the [VSCode Marketplace] and [Open VSX Registry]. This release has the following changes: • Highlight `rec' keyword in OCaml mli files for recursive modules ([#434]) • Highlight `cram' stanza in dune-project files ([#441]) • Fix reason highlighting of let extensions ([#447]) • Improve highlighting of Menhir new syntax ([#450]) • Improve Menhir syntax highlighting ([#455]) • Add `Alt + P' keyboard shortcut for infer interface code action ([#448]) • Infer interface when switching to a non-existing interface file ([#437]) This is the first release to be automatically published to Open VSX, which will benefit users of [VSCodium] and other editors. Please feel free to share feedback. [VSCode OCaml Platform] [VSCode Marketplace] [Open VSX Registry] [#434] [#441] [#447] [#450] [#455] [#448] [#437] [VSCodium] Database modelling ══════════════════ Archive: Reviving this very old thread, paul announced ───────────────────────────────────────────── And a version for postgresql: Opium 0.19.0 ════════════ Archive: Thibaut Mattio announced ──────────────────────── On behalf of the Opium team, I am pleased to announce a new version of Opium (`0.19.0') is available on Opam. This release comes with a complete rewrite of Opium's internals to switch from Cohttp to Httpaf (work done by @anuragsoni). As demonstrated in several benchmarks, Httpaf's latency is much lower than Cohttp's in stress tests, so it is expected that Opium will perform better in these high-pressure situations. The underlying HTTP server implementation is now contained in a `rock' package, that provides a Service and Filter implementation, inspired by Finagle's. The architecture is similar to Ruby's Rack library (hence the name), so one can compose complex web applications by combining Rock applications. The `rock' package offers a very slim API, with very few dependencies, so it should be an attractive option for other Web frameworks to build on, which would allow the re-usability of middlewares and handlers, independently of the framework used (e.g. one could use Sihl middlewares with Opium, and vice versa). Apart from the architectural changes, this release comes with a lot of additional utilities and middlewares which should make Opium a better candidate for complex web applications, without having to re-write a lot of common Web server functionalities. The Request and Response modules now provide: • JSON encoders/decoders with `Yojson' • HTML encoders/decoders with `Tyxml' • XML encoders/decoders with `Tyxml' • SVG encoders/decoders with `Tyxml' • multipart/form encoders/decoders with `multipart_form_data' • urlencoded encoders/decoders with `Uri' And the following middlewares are now built-in: • `debugger' to display an HTML page with the errors in case of failures • `logger' to log requests and responses, with a timer • `allow_cors' to add CORS headers • `static' to serve static content given a custom read function (e.g. read from S3) • `static_unix' to serve static content from the local filesystem • `content_length' to add the `Content-Length' header to responses • `method_override' to replace the HTTP method with the one found in the `_method' field of `application/x-www-form-urlencoded' encoded `POST' requests. • `etag' to add `ETag' header to the responses and send an HTTP code `304' when the computed ETag matches the one specified in the request. • `method_required' to filter the requests by the HTTP method and respond with an HTTP code `405' if the method is not allowed. • `head' to add supports for `HEAD' request for handlers that receive `GET' requests. Lastly, this release also adds a package `opium-testing' that can be used to test Opium applications with Alcotest. It provides `Testable' modules for every Opium types, and implements helper functions to easily get an `Opium.Response' from an `Opium.Request'. As this release changes the API drastically, we will keep maintaining the `0.18.0' branch for bug fixes, for users who don't want to (or can't) migrate to `0.19.0'. What's next? ╌╌╌╌╌╌╌╌╌╌╌╌ Recent discussions have shown that building optimized applications was not trivial. This is partly due to the lack of documentation, and probably because some configurations that should come by default, are left to the user to optimize. Therefore, we will keep performance in mind for the next release and investigate the current bottlenecks in Opium. We will also continue adding higher-level functionalities to Opium to make users productive with real-world applications. This includes: • Sessions support (with signed cookies) • Handlers for authentication • Adding more middlewares (compression, flash messages, caching, etc.) Your feedback is welcome, don't hesitate to open Issues on Github! Andreas Poisel asked and Anurag Soni replied ──────────────────────────────────────────── Does Opium + Httpaf support TLS? It doesn't at the moment. Calascibetta Romain then said ───────────────────────────── According the interface of `opium', it's possible to have the support of TLS (with `ocaml-tls') with the [new version of Conduit] and [`paf'] (which is a MirageOS compatible layer of HTTP/AF - unreleased): ┌──── │ let stack ip = │ Tcpip_stack_socket.UDPV4.connect (Some ip) >>= fun udpv4 -> │ Tcpip_stack_socket.TCPV4.connect (Some ip) >>= fun tcpv4 -> │ Tcpip_stack_socket.connect [ ip ] udpv4 tcpv4 │ │ let http_with_conduit (ip, port) error_handler request_handler = │ Paf.https httpaf_config ~error_handler ~request_handler:(fun _ -> request_handler) │ ({ Paf.TCP.stack= stack ip │ ; keepalive= None │ ; nodelay= false │ ; port= port}, Tls.Config.server ~certificates ()) │ │ let () = match Lwt_main.run (Opium.run (https_with_conduit (Ipaddr.V4.localhost, 4343)) opium_app) with │ | Ok () -> () │ | Error err -> Fmt.epr "%a.\n%!" Conduit_mirage.pp_error err └──── I used it for a long time on my personal unikernels and did some tests to ensure that [it does fails when it handles many requests]. Note that you are able to use OpenSSL too if you want. [new version of Conduit] [`paf'] [it does fails when it handles many requests] Robin Björklin also replied ─────────────────────────── If you want to use this new version of Opium there are ways around this problem. You could have Haproxy (or similar) terminate your TLS connections externally and if your environment requires TLS for your internal network something like [Consul Connect] can cover that use-case for you. [Consul Connect] Operator lookup tool for OCaml ══════════════════════════════ Archive: Craig Ferguson announced ──────────────────────── I'm pleased to announce the initial release of craigfe.io/operator-lookup/, a search tool for OCaml operators and syntax elements: For each operator, the tool provides a short explanation of its behaviour, examples of usage and warnings of common misuses and misunderstandings: The intent of writing this tool was to give OCaml beginners a quick way to find the standard / conventional operators in the language and to disambiguate "operator-like" syntax that can be hard to search for otherwise. It currently supports: • all standard library operators, • conventional infix operators (`>>=', `>>|', `>|='), • binding operators (`let+', `let*', `and+', etc.), • syntax that is often confused for an operator (`#', `;;'). Please let me know if you have any suggestions for improvements. I hope you find it useful! Acknowledgements ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ This tool is heavily based on the [JavaScript operator lookup] utility by [Josh Comeau]. Thanks to him for the initial idea and for allowing me to re-use his design elements. [JavaScript operator lookup] [Josh Comeau] Kakadu asked and Craig Ferguson replied ─────────────────────────────────────── It's not obvious for me are these operators hardcoded or do you scan opam packages from time to time? They're hardcoded. The operators fall into three classes: • The vast majority of them are from the `Stdlib' module, so I don't expect those to change very regularly. • A small number of "conventional" operators used in the community (`>>=', `let*', etc.). Even for that small set there is some divergence in Opam – c.f. `>>|' vs `>|=' for a _map_ operator – so I suspect there are not many other candidates for this group. • There are a few regexes behind the scenes for catching valid operator names that don't fall into the first two categories. e.g. many search terms are classified as "_a left-associative operator_" with a correspondingly vague description. Other OCaml News ════════════════ From the ocamlcore planet blog ────────────────────────────── Here are links from many OCaml blogs aggregated at [OCaml Planet]. • [“Universal” Dune Tip: Rebuild Stuff, Sometimes] [OCaml Planet] [“Universal” Dune Tip: Rebuild Stuff, Sometimes] 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]