Hello Here is the latest OCaml Weekly News, for the week of March 14 to 21, 2023.
Table of Contents ───────────────── Js_of_ocaml 5.1 Petrol 1.2.0 release - Postgres Support + User-extensible types Docfd: TUI fuzzy document finder 0.2.3 OCamlot - Activitypub server written in OCaml new versions of VS Code extensions Alcotest and Expect and Inline tests, now on Open VSX too Autofonce, a modern runner for GNU Autotests suites Release of piece_rope 0.9.0 Old CWN Js_of_ocaml 5.1 ═══════════════ Archive: <https://discuss.ocaml.org/t/ann-js-of-ocaml-5-1/11662/1> Hhugo announced ─────────────── I’m pleased to announce the release of js_of_ocaml 5.1. It should soon be able available in opam. Js_of_ocaml is a compiler from OCaml bytecode to JavaScript. It makes it possible to run pure OCaml programs in JavaScript environment like browsers and Node.js. This release includes many significant changes. Here are some of the notable ones: • Js_of_ocaml now understands most `es6' features (but `import' and `export') • JavaScript files generated by js_of_ocaml are now UTF-8 encoded. • Change the memory representation of OCaml strings to use JS ones. String still represent sequences of bytes and only contains codepoints in the range `[0-255]'. • Improved support for OCaml 5 effects, performing partial CPS transformation to significantly improve perfs (see <http://ocsigen.org/js_of_ocaml/5.1.0/manual/performances>) • Various improvements to make the compiler faster. • Separate compilation only link compilation units that are needed, similar to `ocamlc', and generate much smaller js files See the [Changelog] for other changes. [Changelog] <https://github.com/ocsigen/js_of_ocaml/blob/master/CHANGES.md> Petrol 1.2.0 release - Postgres Support + User-extensible types ═══════════════════════════════════════════════════════════════ Archive: <https://discuss.ocaml.org/t/ann-petrol-1-2-0-release-postgres-support-user-extensible-types/11691/1> Kiran Gopinathan announced ────────────────────────── I’m pleased to announce the latest release of Petrol - [A high level typed SQL API for OCaml] (in the process of being published to opam). This latest release is exciting as it now adds Postgresql support (previously Petrol only supported Sqlite3). Petrol makes using SQL from OCaml a breeze: ┌──── │ open Petrol │ open Petrol.Sqlite3 │ │ (* define a new schema *) │ let schema = StaticSchema.init () │ │ (* declare a table *) │ let example_table, Expr.[name; age] = │ StaticSchema.declare_table schema ~name:"example" │ Schema.[ │ field "name" ~ty:Type.text; │ field "age" ~ty:Type.int │ ] └──── and here’s how you write queries: ┌──── │ (* create a query *) │ let insert_person ~name:n ~age:a db = │ Query.insert ~table:example_table │ ~values:Expr.[ │ name := s n; │ age := i a │ ] │ |> Request.make_zero │ |> Petrol.exec db └──── Petrol compiles down to Caqti queries under the hood, and comes with a nifty migration system built-in, so you can seamlesly update your database tables without disrupting end users: ┌──── │ (* declare a table with a migration for a new [age] column in version 1.2.0 *) │ let t, Expr.[id;age;url] = │ VersionedSchema.declare_table db ~name:"person" │ Schema.[ │ field ~constraints:[primary_key ~name:"bookmark_id" ()] "id" ~ty:Type.int; │ field "age" ~ty:Type.int; │ field "url" ~ty:Type.text; │ ] │ ~migrations:[v_1_2_0, [ │ Caqti_request.Infix.(Caqti_type.unit ->. Caqti_type.unit) │ {sql|ALTER TABLE person ADD COLUMN age INTEGER DEFAULT 1000|sql} │ ]] └──── This and more is explained in the documentation, along with a nifty quick-starter guide: <https://gopiandcode.github.io/petrol/petrol/index.html> I’ve spent some time tuning the documentation to make it easy to pick up! You may also want to check out the tests to see it in action: <https://github.com/Gopiandcode/petrol/tree/master/test> Previous discussion: <https://discuss.ocaml.org/t/ann-petrol-1-0-0-a-high-level-typed-sql-api-for-ocaml-designed-to-go-fast/11166> [A high level typed SQL API for OCaml] <https://github.com/Gopiandcode/petrol> Docfd: TUI fuzzy document finder 0.2.3 ══════════════════════════════════════ Archive: <https://discuss.ocaml.org/t/ann-docfd-tui-fuzzy-document-finder-0-2-3/11698/1> Darren announced ──────────────── I’m happy to share Docfd, an interactive TUI tool finding the text file you need quickly. • [Repo] • [Statically linked binary] (Will submit to opam when time frees up a bit.) [Repo] <https://github.com/darrenldl/docfd> [Statically linked binary] <https://github.com/darrenldl/docfd/releases/tag/0.2.3> Screenshots and interface ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ Searching `left is' in the repo root <https://global.discourse-cdn.com/business7/uploads/ocaml/original/2X/9/9afad805f2b647c9229116b7b7648105bcb84a9e.png> Searching `[github]' in the repo root <https://global.discourse-cdn.com/business7/uploads/ocaml/original/2X/9/9623d259c89bbaaf5feb109a42faf7e1dde6010f.png> The TUI is divided into three sections: • Left is the list of documents which satisfy the search constraints • Top right is the preview of the document • Bottom right is the ranked content search result list • Bottom bar is the search interface Controls ╌╌╌╌╌╌╌╌ Docfd operates in modes, the initial mode is `NAVIGATION' mode `NAVIGATION' mode • Scroll down the document list • `j' or down arrow • Scroll down with mouse wheel when hovering above the area • Scroll up the document list • `k' or up arrow • Scroll up with mouse wheel when hovering above the area • Scroll down the content search result list • `Shift~+~j' or ~Shift~+Down arrow • Scroll down with mouse wheel when hovering above the area • Scroll up the document list • `Shift~+~k' or ~Shift~+Up arrow • Scroll up with mouse wheel when hovering above the area • Open document • `Enter' • Docfd tries to use `$VISUAL' first, if that fails then Docfd tries `$EDITOR' • Switch to `CONTENT SEARCH' mode • `/' • Exit Docfd • `q' or `Ctrl+c' `CONTENT SEARCH' mode • Content search field is active in this mode • `Enter' to confirm search constraints and exit search mode Limitations ╌╌╌╌╌╌╌╌╌╌╌ • Docfd is focused on typical desktop use, so simplicity of components is often favoured over strict performance • That being said, the in-memory index and search should still be performant enough • No on-disk index is built OCamlot - Activitypub server written in OCaml ═════════════════════════════════════════════ Archive: <https://discuss.ocaml.org/t/ann-ocamlot-activitypub-server-written-in-ocaml/11699/1> Kiran Gopinathan announced ────────────────────────── I’m pleased to announce the release of a project that I’ve been working on, on-and-off for a while now: an activitypub server in OCaml — OCamlot. <https://github.com/Gopiandcode/ocamlot> It’s wildly incomplete, and currently only the bare-bones minimum to be a considered an activitypub server, but it’s coming along nicely. Currently it supports: • profiles, custom profile pictures, about • likes, reposts • replies and that’s all. Some screenshots: • Feed <https://global.discourse-cdn.com/business7/uploads/ocaml/optimized/2X/6/65e8cbb291c93f6bb1592e7aba861a09879559a9_2_1034x484.png> • Writing replies: <https://global.discourse-cdn.com/business7/uploads/ocaml/optimized/2X/b/be50c1293ab9fd424c10b5855a0ab0402695e56c_2_1034x430.png> • Listing users: <https://global.discourse-cdn.com/business7/uploads/ocaml/optimized/2X/8/861c06d96320d80df7cdfce33825ab3dd911a7c8_2_1034x214.png> • Profile page: <https://global.discourse-cdn.com/business7/uploads/ocaml/optimized/2X/c/ca5d18579af38d44c57fb2d1a813ca5ca5ac85c3_2_1034x386.png> • Post replies <https://global.discourse-cdn.com/business7/uploads/ocaml/optimized/2X/0/079f47b31fd8f54bf3d4fc1943662fb44355af19_2_1034x398.png> Now, the things that this community would care about: • The server is implemented using dream: <https://github.com/Gopiandcode/ocamlot/blob/master/lib/server/server.ml> • The underlying database is Postgres (or Sqlite), accessed from OCaml using Caqti + [Petrol]: <https://github.com/Gopiandcode/ocamlot/blob/master/lib/database/tables.ml> • Ingesting and producing activitypub entities is done using the decoders library: <https://github.com/Gopiandcode/ocamlot/blob/master/lib/activitypub/types.ml> • Rendering is all done server-side using tyxml: <https://github.com/Gopiandcode/ocamlot/tree/master/lib/view> Seeing as there has been some interest in this community recently about activitypub integration in OCaml, I figured this might be interesting. I have an instance running on over at <https://ocamlot.xyz> – as a warning, I’ve done most of my testing locally using pleroma, so there may be some slight issues interacting with other server implementations at the moment. Also would be happy to field any questions regarding navigating the activitypub spec as well. I plan to write up my experiences somewhere at some point in the future. [Petrol] <https://discuss.ocaml.org/t/ann-petrol-1-2-0-release-postgres-support-user-extensible-types/11691> new versions of VS Code extensions Alcotest and Expect and Inline tests, now on Open VSX too ════════════════════════════════════════════════════════════════════════════════════════════ Archive: <https://discuss.ocaml.org/t/ann-new-versions-of-vs-code-extensions-alcotest-and-expect-inline-tests-now-on-open-vsx-too/11700/1> Roland Csaszar announced ──────────────────────── I’ve just updated both VS Code testing extensions, as of now they are available at the Open VSX Registry too. Bugfixes: The Opam environment of the project’s root is used, so the Dune executable in the sandbox of the project directory is used by default if such a sandbox exists. Otherwise the environment of the current Opam switch. If Dune does not work (a call of `dune --version' fails), an error message box is displayed. Expect & Inline PPX ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ • [VS Marketplace] • [Open VSX] • [GitHub] [VS Marketplace] <https://marketplace.visualstudio.com/items?itemName=release-candidate.vscode-ocaml-expect-inline> [Open VSX] <https://open-vsx.org/extension/Release-Candidate/vscode-ocaml-expect-inline> [GitHub] <https://github.com/Release-Candidate/vscode-ocaml-expect-inline> Alcotest & Inline Alcotest ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ • [VS Marketplace] • [Open VSX] • [GitHub] [VS Marketplace] <https://marketplace.visualstudio.com/items?itemName=release-candidate.vscode-ocaml-alcotest-test-adapter> [Open VSX] <https://open-vsx.org/extension/Release-Candidate/vscode-ocaml-alcotest-test-adapter> [GitHub] <https://github.com/Release-Candidate/vscode-ocaml-alcotest-test-adapter> Changelog ╌╌╌╌╌╌╌╌╌ • Add error message window if `dune' does not work in a workspace. ◊ Bugfixes • Use the current Opam environment to be able to use local executables like `dune'. ◊ Internal Changes • Add tests to check the parsing of `opam env'. Autofonce, a modern runner for GNU Autotests suites ═══════════════════════════════════════════════════ Archive: <https://discuss.ocaml.org/t/autofonce-a-modern-runner-for-gnu-autotests-suites/11727/1> Fabrice Le Fessant announced ──────────────────────────── I am not sure it might be helpful to the OCaml community, as we already have well integrated test frameworks, but here is a tool I wrote in OCaml to work with GNU projects: `autofonce' is a modern runner for testsuites created for the GNU Autoconf tools. Compared to Autoconf tools, its main features are: • improved terminal output • automatic parallel execution • promotion of tests results to fix tests • extended syntax • filtering by keywords, numbers and ranges • execution from any project directory A typical Autoconf test looks like: ┌──── │ # Start of a test, and the name that will be displayed │ AT_SETUP([Example test]) │ │ # can be used to select tests to run: │ AT_KEYWORDS([example test autofonce]) │ │ # create a file ~file~ with its content │ AT_DATA([file], [ │ content of file │ on multiple lines │ ]) │ │ # call some command, check its exit code, stdout, stderr │ AT_CHECK([cat file], [0], [stdout of my command], [stderr of my command]) │ # you can do more, ignore some results, run more tests in case of failure, etc. │ │ # end of the test │ AT_CLEANUP └──── I personally like the syntax better than the one of `cram' tests, though there is some weird escaping issues with brackets (see the section in the doc). Compatibility with Autoconf is only partial, as it uses a grammar interpretation of what should actually be `m4' macros, but it was good enough to run the full GnuCOBOL testsuite after a few fixes (that actually improved the testsuite). The package is on Opam, but sources, documentation and static binaries are available from Github: <https://github.com/ocamlpro/autofonce> Release of piece_rope 0.9.0 ═══════════════════════════ Archive: <https://discuss.ocaml.org/t/ann-release-of-piece-rope-0-9-0/11734/1> Humza Shahid announced ────────────────────── I’m not sure how useful this is to others, but I published my first open source package to opam which can be used by anyone interested in it. It is the same data structure used for editing text in VS Code [1] and AbiWord [2], with a few modifications to make it persistent and functional. It provides some nice features on top which include: • Serialising and deserialising the structure to a file for persistent undo/redo. • Translating between offsets of different Unicode encodings (UTF-8, UTF-16 and UTF-32) for interaction with external systems and languages. • There is a computationally expensive function to rebuild the structure, optimising it for memory usage and performance. (The idea was to use this in a GUI app when the user is inactive and rebuilding in that case - the core structure is fast but the perfectionist in me wanted it to be as fast and lean in memory as possible.) There are some similar packages others may find useful like Zed which are a more battle-tested implementation of a similar-but-not-quite-the-same data structure as this is a new implementation. Feel free to comment or open issues for any bugs you find during usage. Hopefully someone else out there will find this useful too. • [1] <https://code.visualstudio.com/blogs/2018/03/23/text-buffer-reimplementation> • [2] <http://e98cuenc.free.fr/wordprocessor/piecetable.html> 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] <mailto:alan.schm...@polytechnique.org> [the archive] <https://alan.petitepomme.net/cwn/> [RSS feed of the archives] <https://alan.petitepomme.net/cwn/cwn.rss> [online] <http://lists.idyll.org/listinfo/caml-news-weekly/> [Alan Schmitt] <https://alan.petitepomme.net/>
_______________________________________________ caml-news-weekly mailing list caml-news-weekly@lists.idyll.org http://lists.idyll.org/listinfo/caml-news-weekly