Hello Here is the latest OCaml Weekly News, for the week of August 31 to September 07, 2021. Table of Contents ───────────────── Just reinvented OOP v3.OCaml.org: A roadmap for OCaml's online presence Become an Outreachy Mentor: support the growth and diversity of the OCaml community Generating static and portable executables with OCaml OCaml quant-developer at Bloomberg. London or New York HTTP client library Other OCaml News Old CWN Just reinvented OOP ═══════════════════ Archive: Yawar Amin said ─────────────── ┌──── │ let ( .![] ) obj f = f obj │ │ type person = { id : int; name : string } │ │ let id { id; _ } = id │ │ let bob = { id = 1; name = "Bob" } │ let next_id = bob.![id].![succ] └──── ==> 2 Kiran Gopinathan replied ──────────────────────── Haha, what a coincidence, just did the same very recently while translating a rust library to OCaml: ┌──── │ let eclasses = eg.@[eclasses] in │ let cost_map = Id.Map.create 10 in │ let node_total_cost node = │ let has_cost id = Id.Map.mem cost_map (eg.@[find] id) in │ if List.for_all has_cost (L.children node) │ then let cost_f id = fst @@ Id.Map.find cost_map (eg.@[find] id) in Some (E.cost cost_f │ node) │ else None in │ (* ... *) └──── with `.@[]' defined as: ┌──── │ let (.@[]) self fn = fn self [@@inline always] └──── for bonus(?) points, you can name the first parameter self: ┌──── │ let add_enode self (node: Id.t L.shape) = │ let node = self.@[canonicalise] node in │ (* ... *) └──── I don't normally write code like this in OCaml, but in this case, it made porting from rust easier, because the code mostly looked the same. hyphenrf also replied ───────────────────── You can use the multiple-indexing syntax to implement slicing (well, technically subs) sugar: ┌──── │ let (.:[;..]) s = function │ | [|start; finish|] -> String.sub s start (finish - start) │ | _ -> raise (Invalid_argument "slice takes exactly two indexes") └──── ┌──── │ # "hello world".:[1;5];; │ - : string = "ello" └──── The new indexing syntax is quite versatile :> Kiran Gopinathan added ────────────────────── Oh wow, this is perfect! brb, off to reimplement the python slicing semantics in OCaml: ┌──── │ let (.@[;..]) ls = function[@warning "-8"] │ | [| start; -1 |] -> │ List.to_iter ls │ |> Iter.zip_i │ |> Iter.drop_while (Pair.fst_map ((>) start)) │ |> Iter.map snd │ | [| start; finish |] -> │ List.to_iter ls │ |> Iter.zip_i │ |> Iter.drop_while (Pair.fst_map ((>) start)) │ |> Iter.take_while (Pair.fst_map ((>) finish)) │ |> Iter.map snd │ | [| start; finish; step |] -> │ List.to_iter ls │ |> Iter.zip_i │ |> Iter.drop_while (Pair.fst_map ((>) start)) │ |> Iter.take_while (Pair.fst_map ((>) finish)) │ |> Iter.filter (Pair.fst_map (fun ind -> (ind - start) mod step = 0)) │ |> Iter.map snd └──── v3.OCaml.org: A roadmap for OCaml's online presence ═══════════════════════════════════════════════════ Archive: Continuing this thread, Anil Madhavapeddy replied to many comments ────────────────────────────────────────────────────────────────── Many thanks for all the constructive comments and suggestions so far, and also for those who have gotten in touch to contribute. Please do keep them coming (either on this thread or on the various issue trackers that @jonludlam and @patricoferris have pointed to). I'll answer some earlier questions here: Having said that, the colors on the [packages landing page ] feel very aggressive to me. Might be my setup here, but I would like to have a slightly less harsh contrast. Also, there is a bit of an overlap in content with [https://ocamlverse.github.io/ ] for some things (eg best practices, community) but the (to me) most valuable feature is missing: The ecosystems overview, where I can find packages sorted thematically. Could such a section also have a place in the packages subpage somewhere? Alternatively, maybe opam can allow to “tag” packages in the future so one could see all packages for graphics, databases etc. The styling of the /packages sub-URL does indeed differ from the main design, but this is simply due to a temporary technical detail. The majority of the site uses React/NextJS to generate the frontend, and this uses the now-trendy medium-contrast colours and also features like fast-page-switching that NextJS offers. However, the documentation portion generated around 2.7 million individual pages when run across the full opam repository, and so we restored to dynamic generation of the content for that. What's going to happen next is a rationalisation of the code across the ReScript and OCaml frontends so that there will be no observable difference in the colour schemes across the full site. Regarding creating a categorised list of recommendations, that is absolutely in scope for the v3 iteration of the site. However, this metadata should ideally live in the opam-repository (for example, using `tags' as you suggest, which opam already supports). If anyone would like to have a go at this, I'd encourage PRs to the opam-repository to add the relevant tag metadata for a codex. Meanwhile, @lambda_foo @tmattio and @patricoferris are working on the core OCaml Platform workflow information for the guides section of the website which will cover opam, merlin, lsp-server, dune and so on. Do we have access to all of the previous years’ workshops to add to [watch.ocaml.org]? I can see pieces of 2015, 2017, 2020 and this year. @avsm Is it possible to add the ML Workshop as well? Absolutely. The watch.ocaml.org has held up nicely after the OCaml Workshop, so I think it's in good shape to populate with more videos. This needs a volunteer to help us upload the past [nine years] of videos from YouTube to watch.ocaml.org. If anyone wants to have a go, please message me and I'll create you an account. It’s a bit unclear what you meant in this paragraph. Does that mean that you plan to kill the ocaml planet ? I would find it a little bit sad. One of the reason why you may feel it doesn’t work well may be that it has been constantly broken in the current version of the site… I'm not sure why you think the current ocaml.org new feed has been broken – it's been working fairly reliably for the past decade. The only real problem came up a few times when a feed's domain expired and got taken over by domain squatters, at which point we got spam into the main page of ocaml.org. What I meant with that part of the announcement is that the syndication feed should not be mistaken with original news on the website. Right now it's difficult to distinguish official announcements (such as compiler or opam releases) as they are a little scattered (e.g. on opam.ocaml.org). The plan is to combine the [platform-blog] with the new website directly. I've also been considering just having a special tag on this forum so that nice announcement posts could also be syndicated to the website easily (for example, @gasche's compiler newsletters). My general desire is to _grow_ the planet feed and syndication system, but to clearly demarcate them as not being published by ocaml.org and to manage them via more modern decentralised techniques that feature spam, moderation and archival. PeerTube is a good example of this for videos that is working well, and I'd welcome suggestions for Atom/RSS (there must be something in this space, ideally ActivityPub-based). Depending on how the experiments go, it's very likely that we'll have a Matrix homeserver for ocaml.org where CI bots can report status information (see this [prototype PR]) for ocaml-ci that will also apply to opam-repository. The goal here is to for ocaml.org to publish its data using an open protocol, which can then be syndicated into whatever technologies are in vogue (e.g. Discord, Slack, Teams, …). So if you spot some decentralised syndication system that you think might be interesting for OCaml, please do let me know. Even better, if you'd like to develop one to tailor it to our needs, let me know even sooner ;-) [packages landing page ] [https://ocamlverse.github.io/ ] [watch.ocaml.org] [nine years] [platform-blog] [prototype PR] Become an Outreachy Mentor: support the growth and diversity of the OCaml community ═══════════════════════════════════════════════════════════════════════════════════ Archive: Anil Madhavapeddy announced ─────────────────────────── There's been a very disappointing response to this call for mentors to increase the diversity of our community. Precisely *noone* has been in touch for the winter call, leaving the burden of mentorship on the same people that did all the work this summer. Before making [new calls for programs like GSoC], let's get Outreachy onto more sustainable ground please. We are purely limited by mentorship time at present. This can be as simple as organising new first issues for projects in the ecosystem, and all the way to pair programming with a mentee. You can chose how to be involved. [new calls for programs like GSoC] Generating static and portable executables with OCaml ═════════════════════════════════════════════════════ Archive: OCamlPro announced ────────────────── It has been a few times now that we have been tasked to generate portable binaries for different projects. Over time, we have gathered quite some know-how and, seeing the question frequently arise in the community, we decided to share this experience. You can find the article written by Louis Gesbert on[ the OCamlPro blog] Distributing OCaml software on opam is great (if I dare say so myself), but sometimes you need to provide your tools to an audience outside of the OCaml community, or just without recompilations or in a simpler way. However, just distributing the locally generated binaries requires that the users have all the required shared libraries installed, and a compatible libc. It's not something you can assume in general, and even if you don't need any C shared library or are confident enough it will be installed everywhere, the libc issue will arise for anyone using a distribution based on a different kind, or a little older than the one you used to build. There is no built-in support for generating static executables in the OCaml compiler, and it may seem a bit tricky, but it's not in fact too complex to do by hand, something you may be ready to do for a release that will be published. So here are a few tricks, recipes and advice that should enable you to generate truly portable executables with no external dependency whatsoever. Both Linux and macOS will be treated, but the examples will be based on Linux unless otherwise specified. Don't hesitate to share your thoughts with us, have a good reading! [ the OCamlPro blog] OCaml quant-developer at Bloomberg. London or New York ══════════════════════════════════════════════════════ Archive: Philip Craig announced ────────────────────── Extend a financial contracts DSL that is implemented in OCaml. It's London or New York based. It's not a remote position. Please see details and/or apply at () HTTP client library ═══════════════════ Archive: Hannes Mehnert announced ──────────────────────── we just released to the opam-repository the [`http-lwt-client'] package, which consists of both a library doing HTTP requests and a binary (`hurl') that does HTTP requests. The code is based on [HTTP/AF] and [H2], and uses [tls] for HTTPS connections. Both HTTP/1(.1) and HTTP/2 protocols are supported. The motivation behind this package is to have a http client that has a reasonably small dependency cone, is purely implemented in OCaml, and uses the asynchronous task library lwt. This package uses [happy-eyeballs] to connect to a remote host via IPv4 and IPv6, as proposed by IETF [RFC 8305]: on any computer with either IPv4 or IPv6 connectivity, a remote IPv6 or IPv4 server will be connected. Preference is given to IPv6. If a https url is provided, the server certificate is verified using the [ca-certs] package. If you experience any issues or have further needs for this package, please report an issue on the GitHub issue tracker. The installation is just an `opam install http-lwt-client' away :) [`http-lwt-client'] [HTTP/AF] [H2] [tls] [happy-eyeballs] [RFC 8305] [ca-certs] Hannes Mehnert later added ────────────────────────── now [0.0.2] is released that unifies the response type and API (previously it was a variant and clients had to write code for both HTTP1 and HTTP2). Now, a single record and Status/Headers/Version module aliases are provided (very close to HTTP/AF). Enjoy. [0.0.2] Other OCaml News ════════════════ From the ocamlcore planet blog ────────────────────────────── Here are links from many OCaml blogs aggregated at [OCaml Planet]. • [Goodbye Core_kernel] • [Tarides Engineers to Present at ICFP 2021] • [Benchmarking OCaml projects with current-bench] • [What the interns have wrought, 2021 edition] [OCaml Planet] [Goodbye Core_kernel] [Tarides Engineers to Present at ICFP 2021] [Benchmarking OCaml projects with current-bench] [What the interns have wrought, 2021 edition] 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]