# Learning

**URL:** https://discuss.ocaml.org/c/learning/7.md?page=3

[Latest](https://discuss.ocaml.org/latest.md) · [Categories](https://discuss.ocaml.org/categories.md) · [Tags](https://discuss.ocaml.org/tags.md)

**Page:** 4

---

## [Capnp-rpc Fiber.fork with expect tests](https://discuss.ocaml.org/t/capnp-rpc-fiber-fork-with-expect-tests/17874)

<div class="topic-metadata">

**Author:** [@Mohan\_Radhakrishnan](https://discuss.ocaml.org/u/Mohan_Radhakrishnan)\
**Replies:** 1\
**Last updated:** [March 7, 2026, 12:22pm UTC](https://discuss.ocaml.org/t/capnp-rpc-fiber-fork-with-expect-tests/17874 "2026-03-07T12:22:58Z")

</div>

Hello, My client code has expect tests following this function. let new\_cluster no\_of\_nodes env = let listen\_address = \[\`TCP ("127.0.0.1", 8888) ;\`TCP ("127.0.0.1", 7777)\] in Eio.Switch.run (fun sw -\> let li…

---

## [Partial match: Style advice](https://discuss.ocaml.org/t/partial-match-style-advice/17869)

<div class="topic-metadata">

**Author:** [@jbe](https://discuss.ocaml.org/u/jbe)\
**Replies:** 19\
**Last updated:** [March 6, 2026, 1:43pm UTC](https://discuss.ocaml.org/t/partial-match-style-advice/17869 "2026-03-06T13:43:55Z")

</div>

Consider the following two match … with statements (in f1 and f2) respectively: let g = function x when x \< 0 -\> -1 | \_ -\> 1 let f1 x = let s = g x in string\_of\_int (s \* x) ^ match\[@warning "-partial-match"\] s …

---

## [How to use Raven/Nx with jupyter-notebook?](https://discuss.ocaml.org/t/how-to-use-raven-nx-with-jupyter-notebook/17857)

<div class="topic-metadata">

**Author:** [@marc](https://discuss.ocaml.org/u/marc)\
**Replies:** 3\
**Last updated:** [February 27, 2026, 4:00pm UTC](https://discuss.ocaml.org/t/how-to-use-raven-nx-with-jupyter-notebook/17857 "2026-02-27T16:00:33Z")

</div>

Hello everyone, I’m trying to translate some python tutorials for scientific computing using Raven/Nx with jupyter notebook. I installed raven and jupter-notebook from OCaml Jupyter | An OCaml kernel for Jupyter noteboo…

---

## [(Physically) identifying immutable data structures](https://discuss.ocaml.org/t/physically-identifying-immutable-data-structures/17850)

<div class="topic-metadata">

**Author:** [@jbe](https://discuss.ocaml.org/u/jbe)\
**Replies:** 6\
**Last updated:** [February 26, 2026, 11:39pm UTC](https://discuss.ocaml.org/t/physically-identifying-immutable-data-structures/17850 "2026-02-26T23:39:38Z")

</div>

Hi, I would like to create a unique identifier for an immutable data structure. On non-mutable types, physical equality is implementation dependent. I wonder what’s the best approach: Create an int Atomic.t and use A…

---

## [DAG of .ml\[l/y\] files in a directory](https://discuss.ocaml.org/t/dag-of-ml-l-y-files-in-a-directory/17843)

<div class="topic-metadata">

**Author:** [@710Randy](https://discuss.ocaml.org/u/710Randy)\
**Replies:** 2\
**Last updated:** [February 25, 2026, 9:56pm UTC](https://discuss.ocaml.org/t/dag-of-ml-l-y-files-in-a-directory/17843 "2026-02-25T21:56:19Z")

</div>

What workflow is used to create and print the DAG illustraing the dependencies between .ml\[l\] files in a directory? In my specific case I’m trying to illustrate the DAG for the utop/src/lib with uTop\_main.ml being the d…

---

## [Language manual: floatarray documentation?](https://discuss.ocaml.org/t/language-manual-floatarray-documentation/17844)

<div class="topic-metadata">

**Author:** [@Piero\_Furiesi](https://discuss.ocaml.org/u/Piero_Furiesi)\
**Replies:** 6\
**Last updated:** [February 25, 2026, 12:53pm UTC](https://discuss.ocaml.org/t/language-manual-floatarray-documentation/17844 "2026-02-25T12:53:00Z")

</div>

Hi everyone, I put myself in the shoes of a beginner looking for the predefined types in the OCaml manual. The floatarray type has been introduced since release 4.6.0 to make the choice between boxed vs. unboxed repres…

---

## [Exception UTF-8 inconsistently printing as an escaped string](https://discuss.ocaml.org/t/exception-utf-8-inconsistently-printing-as-an-escaped-string/17841)

<div class="topic-metadata">

**Author:** [@jrfondren](https://discuss.ocaml.org/u/jrfondren)\
**Replies:** 1\
**Last updated:** [February 24, 2026, 7:34am UTC](https://discuss.ocaml.org/t/exception-utf-8-inconsistently-printing-as-an-escaped-string/17841 "2026-02-24T07:34:51Z")

</div>

With a test.ml that contains just failwith “тест”, my guard is lowered by this printing as shown here, and then in a real program it prints as string escapes. What’s responsible for that? $ ocaml test.ml Exception: Fail…

---

## [Vdom "select" html element : unable to prevent default](https://discuss.ocaml.org/t/vdom-select-html-element-unable-to-prevent-default/17830)

<div class="topic-metadata">

**Author:** [@frederic-lang](https://discuss.ocaml.org/u/frederic-lang)\
**Replies:** 4\
**Last updated:** [February 23, 2026, 3:25pm UTC](https://discuss.ocaml.org/t/vdom-select-html-element-unable-to-prevent-default/17830 "2026-02-23T15:25:15Z")

</div>

Hi, I am trying some experiment with Ocaml-vdom (version 0.3). I am trying to build a HTML selectable list of item that actually never changes the value selected. The list shows a selected value when it appears, and ne…

---

## [When to use iarray instead of array?](https://discuss.ocaml.org/t/when-to-use-iarray-instead-of-array/17838)

<div class="topic-metadata">

**Author:** [@jbe](https://discuss.ocaml.org/u/jbe)\
**Replies:** 16\
**Last updated:** [February 23, 2026, 10:37am UTC](https://discuss.ocaml.org/t/when-to-use-iarray-instead-of-array/17838 "2026-02-23T10:37:25Z")

</div>

Stumbling upon this other thread, I realized that OCaml has support for immutable arrays: And indeed, those are part of OCaml 5.4: module Iarray and also a type iarray (for which I don’t seem to find an entry in the ma…

---

## [Selectively bringing constructors or record fields into scope](https://discuss.ocaml.org/t/selectively-bringing-constructors-or-record-fields-into-scope/17821)

<div class="topic-metadata">

**Author:** [@jbe](https://discuss.ocaml.org/u/jbe)\
**Replies:** 18\
**Last updated:** [February 20, 2026, 5:03pm UTC](https://discuss.ocaml.org/t/selectively-bringing-constructors-or-record-fields-into-scope/17821 "2026-02-20T17:03:23Z")

</div>

Continuing the discussion from Generic numeric module, Problem with types: I solve this by not doing open of modules unless they have specifically been designed for opening \[…\] I noticed that open seems to be the on…

---

## [Problems communicating with a child process](https://discuss.ocaml.org/t/problems-communicating-with-a-child-process/17827)

<div class="topic-metadata">

**Author:** [@vrotaru](https://discuss.ocaml.org/u/vrotaru)\
**Replies:** 2\
**Last updated:** [February 19, 2026, 6:43am UTC](https://discuss.ocaml.org/t/problems-communicating-with-a-child-process/17827 "2026-02-19T06:43:36Z")

</div>

I’ve have a hobby project, OCaml bindings to GTK4 which are not LablGTK. And to check the viability of the concept I wanted something more than a counter demo with 2 buttons. So I decided to port ocaml-top editor as a pr…

---

## [How load an image in OCaml?](https://discuss.ocaml.org/t/how-load-an-image-in-ocaml/17826)

<div class="topic-metadata">

**Author:** [@VictoriousSontichn](https://discuss.ocaml.org/u/VictoriousSontichn)\
**Replies:** 3\
**Last updated:** [February 18, 2026, 9:44pm UTC](https://discuss.ocaml.org/t/how-load-an-image-in-ocaml/17826 "2026-02-18T21:44:47Z")

</div>

Hello, I’m currently learning OCaml and I’m trying to edit PNG images. My idea is to introduce the following type : type image = (int \* int \* int) array array;; (a matrix whose coefficients are pixels represented by t…

---

## [I cannot center a widget using GBin.alignment](https://discuss.ocaml.org/t/i-cannot-center-a-widget-using-gbin-alignment/17824)

<div class="topic-metadata">

**Author:** [@SpiceGuid](https://discuss.ocaml.org/u/SpiceGuid)\
**Replies:** 2\
**Last updated:** [February 18, 2026, 8:32pm UTC](https://discuss.ocaml.org/t/i-cannot-center-a-widget-using-gbin-alignment/17824 "2026-02-18T20:32:23Z")

</div>

Hello fellow OCaml-ers :camel: , I discover the joy of LablGTK 2.18.14 :grinning\_face\_with\_smiling\_eyes: My tiny Squava toy GTK2 GUI : When i rezise the window, the GtkDrawingArea gets stuck at top-left corner inste…

---

## [Memory leak when converting coroutine (with effects) to sequence](https://discuss.ocaml.org/t/memory-leak-when-converting-coroutine-with-effects-to-sequence/17816)

<div class="topic-metadata">

**Author:** [@jbe](https://discuss.ocaml.org/u/jbe)\
**Replies:** 3\
**Last updated:** [February 17, 2026, 7:24am UTC](https://discuss.ocaml.org/t/memory-leak-when-converting-coroutine-with-effects-to-sequence/17816 "2026-02-17T07:24:03Z")

</div>

I have a recursive function that I want to “yield” a couple of times while it performs recursion. I would then like to convert that function into a sequence, where iterating over the sequence runs the recursive function …

---

## [Is there still support for source-installed OCaml 4.14.2 x86?](https://discuss.ocaml.org/t/is-there-still-support-for-source-installed-ocaml-4-14-2-x86/17811)

<div class="topic-metadata">

**Author:** [@SpiceGuid](https://discuss.ocaml.org/u/SpiceGuid)\
**Replies:** 5\
**Last updated:** [February 17, 2026, 6:31am UTC](https://discuss.ocaml.org/t/is-there-still-support-for-source-installed-ocaml-4-14-2-x86/17811 "2026-02-17T06:31:50Z")

</div>

Hello :camel: , I want to use LablGTK2 because i need full GTK support (GtkDrawingArea, Glade, Rsvg, GnoCanvas, GnomeCanvas, GtkGLArea). So i have VirtualBox emulating Puppy Wary 5.5 x86, kernel 3.8.0 No opam availabl…

---

## [List.sort vs List.fast\_sort (Why would I want a slow unstable sorting?)](https://discuss.ocaml.org/t/list-sort-vs-list-fast-sort-why-would-i-want-a-slow-unstable-sorting/17820)

<div class="topic-metadata">

**Author:** [@jbe](https://discuss.ocaml.org/u/jbe)\
**Replies:** 4\
**Last updated:** [February 16, 2026, 10:49pm UTC](https://discuss.ocaml.org/t/list-sort-vs-list-fast-sort-why-would-i-want-a-slow-unstable-sorting/17820 "2026-02-16T22:49:51Z")

</div>

Neither List.sort nor List.fast\_sort are guaranteed to do stable sorting. Why would I choose List.sort over List.fast\_sort? (Currently they are implemented the same.) From the documentation, List.sort has some memory g…

---

## [Using GADT to model records that share some of their fields](https://discuss.ocaml.org/t/using-gadt-to-model-records-that-share-some-of-their-fields/12240)

<div class="topic-metadata">

**Author:** [@mooreryan](https://discuss.ocaml.org/u/mooreryan)\
**Replies:** 7\
**Last updated:** [February 16, 2026, 4:19pm UTC](https://discuss.ocaml.org/t/using-gadt-to-model-records-that-share-some-of-their-fields/12240 "2026-02-16T16:19:00Z")

</div>

Let’s say I have some data type t that always has a couple of fields and optionally has a few others. Something like this. type t = {w: w; x: x; y: y option; z: z option} Then you could imagine having functions to get…

---

## [Variant mapping to string and back](https://discuss.ocaml.org/t/variant-mapping-to-string-and-back/17813)

<div class="topic-metadata">

**Author:** [@vivanov](https://discuss.ocaml.org/u/vivanov)\
**Replies:** 3\
**Last updated:** [February 16, 2026, 4:16pm UTC](https://discuss.ocaml.org/t/variant-mapping-to-string-and-back/17813 "2026-02-16T16:16:09Z")

</div>

Hey, suppose I have a variant type type basic\_color = | Black | Red | Green | Yellow | Blue | Magenta | Cyan | White let to\_string = function | Black -\> "1" | Red -\> "2" | Green -\> "3" | Yellow…

---

## [How to use Bigarray as a type?](https://discuss.ocaml.org/t/how-to-use-bigarray-as-a-type/17812)

<div class="topic-metadata">

**Author:** [@marc](https://discuss.ocaml.org/u/marc)\
**Replies:** 8\
**Last updated:** [February 16, 2026, 3:59pm UTC](https://discuss.ocaml.org/t/how-to-use-bigarray-as-a-type/17812 "2026-02-16T15:59:42Z")

</div>

I’m trying to write a deep learning inference module in OCaml as a big project, it will be for learning purposes. Then I’m not sure where to start with the types. I want to use it to create shared libraries from onnx mod…

---

## [Menhir : production nonempty\_list(STRING) -\> STRING is never reduced](https://discuss.ocaml.org/t/menhir-production-nonempty-list-string-string-is-never-reduced/17804)

<div class="topic-metadata">

**Author:** [@frederic-lang](https://discuss.ocaml.org/u/frederic-lang)\
**Replies:** 4\
**Last updated:** [February 13, 2026, 8:23pm UTC](https://discuss.ocaml.org/t/menhir-production-nonempty-list-string-string-is-never-reduced/17804 "2026-02-13T20:23:36Z")

</div>

Hi, I am trying to implement a parser for entries (entries are similar to terminal entries) that transform an entry into a list of string. For instance, transform “git commit -m \\”first commit\\”” into \[“git”; “commit”;…

---

## [Reversed byte order when reading data sequentially with input\_byte](https://discuss.ocaml.org/t/reversed-byte-order-when-reading-data-sequentially-with-input-byte/17806)

<div class="topic-metadata">

**Author:** [@mhitza](https://discuss.ocaml.org/u/mhitza)\
**Replies:** 6\
**Last updated:** [February 13, 2026, 10:04am UTC](https://discuss.ocaml.org/t/reversed-byte-order-when-reading-data-sequentially-with-input-byte/17806 "2026-02-13T10:04:46Z")

</div>

I’m trying to read bytes in order from an input channel. Using consecutive byte reads in an array initialization results in data stored in reverse order. Example type elf\_bytes = { ident : int array; } …

---

## [Learning OCaml by writing bindings for a matrix data type written in C](https://discuss.ocaml.org/t/learning-ocaml-by-writing-bindings-for-a-matrix-data-type-written-in-c/17801)

<div class="topic-metadata">

**Author:** [@marc](https://discuss.ocaml.org/u/marc)\
**Replies:** 6\
**Last updated:** [February 13, 2026, 8:07am UTC](https://discuss.ocaml.org/t/learning-ocaml-by-writing-bindings-for-a-matrix-data-type-written-in-c/17801 "2026-02-13T08:07:49Z")

</div>

Hello everyone, I’m new to OCaml and as a start I wanted to write bindings for my C fixed size vector and matrix library. I got the basics working after that I’m not sure where to continue. Any ideas would be appreciate…

---

## [Generic numeric module, Problem with types](https://discuss.ocaml.org/t/generic-numeric-module-problem-with-types/17797)

<div class="topic-metadata">

**Author:** [@jbe](https://discuss.ocaml.org/u/jbe)\
**Replies:** 8\
**Last updated:** [February 12, 2026, 10:51am UTC](https://discuss.ocaml.org/t/generic-numeric-module-problem-with-types/17797 "2026-02-12T10:51:38Z")

</div>

Hi all, I’m trying to write a generic gauss solver that works with floats, rational numbers, etc. As a prerequisite to write a suitable functor, I try to create the following module types and modules (below formatted fo…

---

## [\[ANN\] OCaml examples of computing with encrypted or private data](https://discuss.ocaml.org/t/ann-ocaml-examples-of-computing-with-encrypted-or-private-data/17799)

<div class="topic-metadata">

**Author:** [@xavierleroy](https://discuss.ocaml.org/u/xavierleroy)\
**Replies:** 0\
**Last updated:** [February 11, 2026, 4:55pm UTC](https://discuss.ocaml.org/t/ann-ocaml-examples-of-computing-with-encrypted-or-private-data/17799 "2026-02-11T16:55:32Z")

</div>

Last Fall, I gave a series of lectures on secure computing (computing with encrypted or private data). Here is some companion OCaml code that demonstrates these techniques: GitHub - xavierleroy/secure-computing: Exampl…

---

## [Opam package decentralization](https://discuss.ocaml.org/t/opam-package-decentralization/17738)

<div class="topic-metadata">

**Author:** [@removewingman](https://discuss.ocaml.org/u/removewingman)\
**Replies:** 17\
**Last updated:** [February 10, 2026, 10:44am UTC](https://discuss.ocaml.org/t/opam-package-decentralization/17738 "2026-02-10T10:44:05Z")

</div>

Hello, I think having all OPAM packages centralized in: GitHub - ocaml/opam-repository: Main public package repository for opam, the source package manager of OCaml. creates a bottleneck. I don’t really see the advantag…

---

## [Using package postgresql and waiting for a notify](https://discuss.ocaml.org/t/using-package-postgresql-and-waiting-for-a-notify/17780)

<div class="topic-metadata">

**Author:** [@jbe](https://discuss.ocaml.org/u/jbe)\
**Replies:** 3\
**Last updated:** [February 7, 2026, 9:40am UTC](https://discuss.ocaml.org/t/using-package-postgresql-and-waiting-for-a-notify/17780 "2026-02-07T09:40:06Z")

</div>

I’m using the postgresql package and would like to wait for a NOTIFY without repeatedly polling. The connection class provides the methods #consume\_input and #socket which could be used in a loop with Unix.select. This …

---

## [Help debug ocaml async websocket echo client](https://discuss.ocaml.org/t/help-debug-ocaml-async-websocket-echo-client/17782)

<div class="topic-metadata">

**Author:** [@vivanov](https://discuss.ocaml.org/u/vivanov)\
**Replies:** 2\
**Last updated:** [February 7, 2026, 3:52am UTC](https://discuss.ocaml.org/t/help-debug-ocaml-async-websocket-echo-client/17782 "2026-02-07T03:52:08Z")

</div>

Hey, I am connecting a client to the web sockets org echo server. This is my code open Core open Async let send\_and\_receive () = let uri = Uri.of\_string "wss://echo.websocket.org" in print\_endline "connecting"; …

---

## [When to use types or modules in functor signatures?](https://discuss.ocaml.org/t/when-to-use-types-or-modules-in-functor-signatures/17777)

<div class="topic-metadata">

**Author:** [@jbe](https://discuss.ocaml.org/u/jbe)\
**Replies:** 4\
**Last updated:** [February 5, 2026, 8:21pm UTC](https://discuss.ocaml.org/t/when-to-use-types-or-modules-in-functor-signatures/17777 "2026-02-05T20:21:07Z")

</div>

Say I have a module that works with elements which can be compared and have a default value (zero), according to the following module type: module type Element = sig type t val compare : t -\> t -\> int val zero : …

---

## [Local type definition](https://discuss.ocaml.org/t/local-type-definition/12036)

<div class="topic-metadata">

**Author:** [@Lupjo](https://discuss.ocaml.org/u/Lupjo)\
**Replies:** 6\
**Last updated:** [February 4, 2026, 10:49pm UTC](https://discuss.ocaml.org/t/local-type-definition/12036 "2026-02-04T22:49:48Z")

</div>

Hello everyone, As far as I know, there is no way to locally define a type, is there a reason for that? I know you can always create polymorphic variants on the fly, but I feel it might be nice to be able to do that. E…

---

## [Learn Programming with OCaml (new book)](https://discuss.ocaml.org/t/learn-programming-with-ocaml-new-book/16111)

<div class="topic-metadata">

**Author:** [@backtracking](https://discuss.ocaml.org/u/backtracking)\
**Replies:** 34\
**Last updated:** [February 2, 2026, 6:14pm UTC](https://discuss.ocaml.org/t/learn-programming-with-ocaml-new-book/16111 "2026-02-02T18:14:39Z")

</div>

Dear OCaml community, A long time ago, Sylvain and I wrote a French book on learning programming with OCaml. Recently, the OCaml Software Foundation funded its translation to English. The book is available here: Learn…

[Previous page](https://discuss.ocaml.org/c/learning/7.md?page=2)

[Next page](https://discuss.ocaml.org/c/learning/7.md?page=4)
