[cwn] Attn: Development Editor, Latest OCaml Weekly News

Alan Schmitt alan.schmitt at polytechnique.org
Tue Nov 8 06:08:33 PST 2022


Hello

Here is the latest OCaml Weekly News, for the week of November 01 to 08,
2022.

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

What’s the well-liked GUI toolkit these days for OCaml
Mini-dalle in OCaml
Mirage retreat October 3rd - 9th
setup-dkml.yml GitHub Actions workflow for distributing binaries
Old CWN


What’s the well-liked GUI toolkit these days for OCaml
══════════════════════════════════════════════════════

  Archive:
  <https://discuss.ocaml.org/t/whats-the-well-liked-gui-toolkit-these-days-for-ocaml/10717/1>


Chet Murthy asked
─────────────────

  I’m looking to display PNG images in a window from OCaml code, and
  would like to put a little window around it with a button to close the
  window, maybe support resizing, stuff like that. I know about Lablgtk
  (and used it lo these many years ago). Is that still the well-liked
  thing?

  I’m of half a mind to just call `www-browser foo.png' and let the
  local web browser deal with it, but that’d doesn’t work so well when
  you’re not on the same machine as the display, ah well.


Carmelo Piccione suggested
──────────────────────────

  I have very little experience in this domain with OCaml so take this
  answer with a grain of salt, but I would probably at least try using
  [lablqml].

  I know some developers have attempted to write a pure functional gui
  api in OCaml from scratch but I can’t recall what those projects are
  called. Someone else on this forum will hopefully dig it up for you.

  Good luck and report back with which one you end up choosing!

  (my guess is targeting the web browser is a lot easier than a native
  gui these days, unfortunately)


[lablqml] <https://kakadu.github.io/lablqml/>


sanette also suggested
──────────────────────

  if you allow me to advertise a library of mine, I think that [bogue]
  should be able to do what you want.


[bogue] <https://github.com/sanette/bogue>


Vladimir Keleshev said
──────────────────────

  I’m pretty sure that [raylib-ocaml] by @tjammer can manage this.


[raylib-ocaml] <https://github.com/tjammer/raylib-ocaml>


David Declerck suggested
────────────────────────

  You could use [OCaml-Canvas] ([documentation]). It’s a new vector
  graphics library I’m developing for OCaml, and among its features, it
  can load PNGs and handle windows and mouse/keyboard events (using
  React). It works on Linux/macOS/Windows and also in web browsers
  (through HTML5 canvases, hence the similar interface).

  It has not been “officially” released yet, but should be soon enough.
  Don’t hesitate to experiment with it !

  Here’s how you can use it to load and display a PNG :
  ┌────
  │ open OcamlCanvas.V1
  │
  │ let () =
  │
  │   Backend.init ();
  │
  │   let c = Canvas.createFramed "Image view" ~pos:(300, 200) ~size:(400, 400) in
  │
  │   Canvas.show c;
  │
  │   let e1 =
  │     React.E.map (fun img ->
  │         let size = ImageData.getSize img in
  │         Canvas.setSize c size;
  │         Canvas.putImageData c ~dpos:(0, 0) img ~spos:(0, 0) ~size
  │       ) (ImageData.createFromPNG "assets/image.png")
  │   in
  │
  │   let e2 =
  │     React.E.map (fun _ ->
  │         Backend.stop ()
  │       ) Event.close
  │   in
  │
  │   Backend.run (fun () -> ignore e1; ignore e2)
  └────


[OCaml-Canvas] <https://github.com/OCamlPro/ocaml-canvas>

[documentation]
<https://ocamlpro.github.io/ocaml-canvas/doc/ocaml-canvas/OcamlCanvas/index.html>


Chet Murthy then clarified
──────────────────────────

  With so many good answers, I thought I’d ask about more functionality:
  This image is a visualization of a quantum circuit. It’s built out of
  a bunch of boxes-and-lines, using the Python `matplotlib' library. I’d
  like to generate such images from OCaml. Obviously, I could just call
  Python (and heck, just call Qiskit’s visualization library), but … I’m
  picky and want to do it without Python.

  <https://qiskit.org/documentation/_images/tutorials_circuits_advanced_03_advanced_circuit_visualization_7_0.png>

  Is there a nice boxes-and-lines drawing package, that I might be able
  to use to draw such a thing? For reference, there’s a Latex package
  that uses a latex `\xymatrix' environment to draw passable circuits:

  <https://global.discourse-cdn.com/standard11/uploads/ocaml/original/2X/2/210b6fab274212948a84752328b96ea6d0eaa3a8.png>

  and I can generate the inputs to that already. So this is really a
  “stretch goal” /grin/.


Edwin Török suggested
─────────────────────

  You could try
  <https://erratique.ch/software/vg/doc/Vg/index.html#basics>, it should
  have most of the primitives you’d need to compose such an image, and
  although it doesn’t seem to have builtin support for drawing aligned
  to a grid, there is a combinator to `move` a piece of an image, so
  should be possible to define something higher level that computes the
  coordinates needed for that. It can output SVG which will probably be
  useful for rendering the drawings on the web.


sanette also replied
────────────────────

  it does not fully answer your question, but you might be interested in
  this [post]. The question was a bit similar, but with less
  sophisticated graphics. Of course, in principle you can use SDL
  primitives to obtain whatever you need, but it will require some work.
  In your case, since you don’t need animations or fancy stuff like
  this, I suppose it would be quite appropriate to use [ocaml-cairo] to
  produce your image. This can be integrated directly within bogue with
  [bogue-cairo]


[post] <https://discuss.ocaml.org/t/ann-bogue-the-ocaml-gui/9099/23>

[ocaml-cairo] <https://github.com/Chris00/ocaml-cairo>

[bogue-cairo] <https://github.com/sanette/bogue-cairo>


zapashcanon suggested
─────────────────────

  Maybe Mlpost could work for you ? See [github] and the [paper (in
  french)].


[github] <https://github.com/backtracking/mlpost>

[paper (in french)]
<https://www.lri.fr/~filliatr/ftp/publis/mlpost-fra.pdf>


Mini-dalle in OCaml
═══════════════════

  Archive: <https://discuss.ocaml.org/t/mini-dalle-in-ocaml/10765/1>


Arul announced
──────────────

  I wanted to announce my work of porting mini-dalle to OCaml
  <https://github.com/ArulselvanMadhavan/mini_dalle>

  I’m looking for feedback as I look to publish this to opam in the near
  future.

  Thanks @laurent for suggesting that I share this here!


Danielo Rodríguez asked and Arul replied
────────────────────────────────────────

        Yep, I saw that, but does it require any extra setup?
        Training files, or AI models or something like that? Is it
        supposed to be executed in an environment like Google
        colab or something? Sorry, I just have very little
        experience with AI

  I see. I could write up a section on what it does.

  All the user has to do is build the docker image with “make
  mini-dalle” and run the dune exec command as shown in the Readme.

  In the background this is what happens:

  1. On the first run, It downloads pretrained weights from a repo and
     saves them in a directory
  2. Download takes some time around 10 mins and approx 7GB space
  3. It then, runs the inference path by converting text to text tokens,
     text tokens to image tokens and image tokens to image. This takes
     about 30 seconds on a A100 GPU. On the CPU, it will take longer
     around 5-7 mins
  4. In the subsequent runs, it just uses the downloaded weights and
     starts running from step 3.

  I can add a notebook in the future. Right now, it just works from the
  command line. Hope it helps!


Mirage retreat October 3rd - 9th
════════════════════════════════

  Archive:
  <https://discuss.ocaml.org/t/mirage-retreat-october-3rd-9th/10363/2>


Continuing this thread, Hannes Mehnert announced
────────────────────────────────────────────────

  To follow up, we have various reports from participants about the
  retreat:
  • Raphaël
    <https://raphael-proust.gitlab.io/code/mirage-retreat-2022-10.html>
  • Jules, Sayo, Enguerrand, Sonja, Jan, Lucas
    <https://tarides.com/blog/2022-10-28-the-mirageos-retreat-a-journey-of-food-cats-and-unikernels>
  • Pierre
    <http://blog.enssat.fr/2022/10/pierre-alain-enssat-teacher-at-11th.html>
  • Hannes <https://mirage.io/blog/2022-11-07.retreat>

  Enjoy reading, and take care. :smiley: :camel: :desert: :ocean:
  :surfing_woman:


setup-dkml.yml GitHub Actions workflow for distributing binaries
════════════════════════════════════════════════════════════════

  Archive:
  <https://discuss.ocaml.org/t/ann-setup-dkml-yml-github-actions-workflow-for-distributing-binaries/10308/2>


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

  There is a new major version 1.1.0 available. It is not
  backwards-compatible but it adds:
  • Supports GitLab CI/CD in addition to GitHub Actions
  • Supports testing/troubleshooting/developing your CI on your desktop
    (macOS, Linux if you have Docker, and Windows if you have Visual
    Studio). You do _not_ need DKML installed on your machine.

  The only known issue is that GitLab CI/CD sometimes kills the Windows
  build of the OCaml compiler when using the shared GitLab SaaS runner;
  retrying the job usually fixes that.

  If you had used the `v0' series of the workflow, that version will
  continue to be supported for a few months but won’t get any updates
  unless the update is critical.

  <https://github.com/diskuv/dkml-workflows#readme>

  /Upgrading?/ The most straightforward way is to introduce `1.1.0' into
  your project (see the link above) and only after it is working you
  should remove the `v0' GitHub child workflow.


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.schmitt at 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/>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/caml-news-weekly/attachments/20221108/125e030b/attachment-0001.html>


More information about the caml-news-weekly mailing list