# Learning

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

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

**Page:** 3

---

## [Biscuit token binding](https://discuss.ocaml.org/t/biscuit-token-binding/18086)

<div class="topic-metadata">

**Author:** [@fmp88](https://discuss.ocaml.org/u/fmp88)\
**Replies:** 4\
**Last updated:** [May 25, 2026, 3:24pm UTC](https://discuss.ocaml.org/t/biscuit-token-binding/18086 "2026-05-25T15:24:35Z")

</div>

Hi, I am using Biscuit token for authorization in a distributed system. Would be nice to use it with OCaml as well, so I had a look at their bindings. They use cargo-c to generate the C dependencies from source W…

---

## [How to disable ocamlformat from formatting record into one line?](https://discuss.ocaml.org/t/how-to-disable-ocamlformat-from-formatting-record-into-one-line/18168)

<div class="topic-metadata">

**Author:** [@allonsyeet](https://discuss.ocaml.org/u/allonsyeet)\
**Replies:** 2\
**Last updated:** [May 25, 2026, 8:22am UTC](https://discuss.ocaml.org/t/how-to-disable-ocamlformat-from-formatting-record-into-one-line/18168 "2026-05-25T08:22:23Z")

</div>

I have a record that I’ve formatted like so Ok { x = s.x +. (s.v \*. p.dt); v = s.v +. (-.p.k \*. s.x \*. p.dt) } When I run ocamlformat on this I get this Ok { x = s.x +. (s.v \*. p.dt); v = s.v +. (-.p.k \*. s.x \*. …

---

## [Request for code critique/reivew for first time learner coming from Rust](https://discuss.ocaml.org/t/request-for-code-critique-reivew-for-first-time-learner-coming-from-rust/18165)

<div class="topic-metadata">

**Author:** [@allonsyeet](https://discuss.ocaml.org/u/allonsyeet)\
**Replies:** 3\
**Last updated:** [May 24, 2026, 11:26am UTC](https://discuss.ocaml.org/t/request-for-code-critique-reivew-for-first-time-learner-coming-from-rust/18165 "2026-05-24T11:26:20Z")

</div>

I decided that I’d learn OCaml by doing something basic I’m familiar with, so I wrote this file for solving a mass on a spring, and I wanted to ask if people could provide any critique/suggestions for improvement/style c…

---

## [Default argument to functors?](https://discuss.ocaml.org/t/default-argument-to-functors/18157)

<div class="topic-metadata">

**Author:** [@fnfun](https://discuss.ocaml.org/u/fnfun)\
**Replies:** 2\
**Last updated:** [May 22, 2026, 11:05am UTC](https://discuss.ocaml.org/t/default-argument-to-functors/18157 "2026-05-22T11:05:24Z")

</div>

I’m trying to create a functor with a sort of polymorphic default argument, but having no luck. Here’s the failed idea: First, a module with a pretty printer for a container element: module type PP = sig type t …

---

## [Dune, ocamldebug, foreign\_stubs](https://discuss.ocaml.org/t/dune-ocamldebug-foreign-stubs/18089)

<div class="topic-metadata">

**Author:** [@Daiwen](https://discuss.ocaml.org/u/Daiwen)\
**Replies:** 8\
**Last updated:** [May 13, 2026, 11:42am UTC](https://discuss.ocaml.org/t/dune-ocamldebug-foreign-stubs/18089 "2026-05-13T11:42:42Z")

</div>

I stumbled upon a bug in a compiler written in ocaml, namely the haxe compiler. I figured I could try to fix it, or at least use ocamldebug to see how I could work around it. I compiled from source and found an annotat…

---

## [\[ANN\] hotseat Squava (a tiny LablGtk2 demo)](https://discuss.ocaml.org/t/ann-hotseat-squava-a-tiny-lablgtk2-demo/17957)

<div class="topic-metadata">

**Author:** [@SpiceGuid](https://discuss.ocaml.org/u/SpiceGuid)\
**Replies:** 1\
**Last updated:** [May 12, 2026, 11:05am UTC](https://discuss.ocaml.org/t/ann-hotseat-squava-a-tiny-lablgtk2-demo/17957 "2026-05-12T11:05:44Z")

</div>

squava.ml - Pastebin.com The Squava board game. The original ./squava.png image : Squava 1.1 has no vector graphics, however you can edit/shrink/stretch ./squava.png and the program will adapt the board using the n…

---

## [What is the significance of a 'witness' in OCaml(or FP)?](https://discuss.ocaml.org/t/what-is-the-significance-of-a-witness-in-ocaml-or-fp/18051)

<div class="topic-metadata">

**Author:** [@Mohan\_Radhakrishnan](https://discuss.ocaml.org/u/Mohan_Radhakrishnan)\
**Replies:** 4\
**Last updated:** [May 11, 2026, 2:22pm UTC](https://discuss.ocaml.org/t/what-is-the-significance-of-a-witness-in-ocaml-or-fp/18051 "2026-05-11T14:22:28Z")

</div>

Hello, I came across this term when I was following the new Java features(Screenshot is attached). It was a JVMLS session. Dreading to ask as my FP knowledge is minimal but even Java is introducing these. I also looked …

---

## [Matching on variants (beginner question!)](https://discuss.ocaml.org/t/matching-on-variants-beginner-question/18083)

<div class="topic-metadata">

**Author:** [@Deverapaza](https://discuss.ocaml.org/u/Deverapaza)\
**Replies:** 2\
**Last updated:** [May 11, 2026, 10:02am UTC](https://discuss.ocaml.org/t/matching-on-variants-beginner-question/18083 "2026-05-11T10:02:00Z")

</div>

Taking first steps in Ocaml (have some background in Python, Rust, Clojure, etc) but already stumbling on the first hurdle… When playing around with variants and matching in utop and trying this code: type rgb\_color = …

---

## [Stack vs List Performance](https://discuss.ocaml.org/t/stack-vs-list-performance/17875)

<div class="topic-metadata">

**Author:** [@patrick-nicodemus](https://discuss.ocaml.org/u/patrick-nicodemus)\
**Replies:** 8\
**Last updated:** [May 8, 2026, 1:31pm UTC](https://discuss.ocaml.org/t/stack-vs-list-performance/17875 "2026-05-08T13:31:32Z")

</div>

I found this exercise in a data structures and algorithms textbook/interview prep book. The idea of the exercises is that towers\_of\_hanoi should take a natural number n and return the sequence of moves that is appropria…

---

## [Functors in Js\_of\_ocaml, type mismatch](https://discuss.ocaml.org/t/functors-in-js-of-ocaml-type-mismatch/18060)

<div class="topic-metadata">

**Author:** [@monomon](https://discuss.ocaml.org/u/monomon)\
**Replies:** 3\
**Last updated:** [May 7, 2026, 8:39pm UTC](https://discuss.ocaml.org/t/functors-in-js-of-ocaml-type-mismatch/18060 "2026-05-07T20:39:17Z")

</div>

Hi, this is probably my misunderstanding of functors, but I could not solve it. I have a module that defines a type for the dom canvas element, but passing it a canvas leads to type mismatch. Alternatively, I guess it c…

---

## [Writing C bindings in 2024](https://discuss.ocaml.org/t/writing-c-bindings-in-2024/15368)

<div class="topic-metadata">

**Author:** [@giltho](https://discuss.ocaml.org/u/giltho)\
**Replies:** 13\
**Last updated:** [May 6, 2026, 10:02pm UTC](https://discuss.ocaml.org/t/writing-c-bindings-in-2024/15368 "2026-05-06T22:02:18Z")

</div>

Hello, This is just a quick post to ask what the current “standard” way of writing C bindings is. By hand? Using Ctypes? I thought it was Ctypes, but the documentation is rather incomplete (or I could not find a more c…

---

## [Misunderstanding of how the type system works](https://discuss.ocaml.org/t/misunderstanding-of-how-the-type-system-works/17836)

<div class="topic-metadata">

**Author:** [@antoineB](https://discuss.ocaml.org/u/antoineB)\
**Replies:** 5\
**Last updated:** [May 6, 2026, 4:00pm UTC](https://discuss.ocaml.org/t/misunderstanding-of-how-the-type-system-works/17836 "2026-05-06T16:00:19Z")

</div>

I have this code in one module file : type list\_command = { search : string option; date : string option; mime : string option; filename : string option; tags : string list; } type add\_command = { tags : st…

---

## [Rocq-released repository with dune package management](https://discuss.ocaml.org/t/rocq-released-repository-with-dune-package-management/18054)

<div class="topic-metadata">

**Author:** [@shilangyu](https://discuss.ocaml.org/u/shilangyu)\
**Replies:** 3\
**Last updated:** [May 6, 2026, 1:32pm UTC](https://discuss.ocaml.org/t/rocq-released-repository-with-dune-package-management/18054 "2026-05-06T13:32:24Z")

</div>

I have Rocq projects that are managed by opam+dune. The standard flow is to: Add the Rocq opam repository: opam repo add rocq-released https://rocq-prover.org/opam/released Run opam install . This works great. But I w…

---

## [OCaml Web tutorials](https://discuss.ocaml.org/t/ocaml-web-tutorials/18039)

<div class="topic-metadata">

**Author:** [@Frederic\_Loyer](https://discuss.ocaml.org/u/Frederic_Loyer)\
**Replies:** 6\
**Last updated:** [May 4, 2026, 1:49pm UTC](https://discuss.ocaml.org/t/ocaml-web-tutorials/18039 "2026-05-04T13:49:20Z")

</div>

I have started a series of OCaml Web tutorials. The idea is to try multiple libraries and see how they fit together. (But the Dream framework document and example set is quite good enough, I will not paraphrase it). For…

---

## [Using ocamlyacc with dune](https://discuss.ocaml.org/t/using-ocamlyacc-with-dune/18019)

<div class="topic-metadata">

**Author:** [@jonathandoyle](https://discuss.ocaml.org/u/jonathandoyle)\
**Replies:** 6\
**Last updated:** [April 27, 2026, 2:37pm UTC](https://discuss.ocaml.org/t/using-ocamlyacc-with-dune/18019 "2026-04-27T14:37:04Z")

</div>

I’ve recently tried to add a my\_parser.mly file to my dune project. My dune file was as follows : (include\_subdirs unqualified) (library (flags -w +1..31+33..69+71+72) (name my\_library\_lib) (libraries str unix zarith) …

---

## [Empty polymorphic variant type?](https://discuss.ocaml.org/t/empty-polymorphic-variant-type/8467)

<div class="topic-metadata">

**Author:** [@viritrilbia](https://discuss.ocaml.org/u/viritrilbia)\
**Replies:** 16\
**Last updated:** [April 21, 2026, 4:02pm UTC](https://discuss.ocaml.org/t/empty-polymorphic-variant-type/8467 "2026-04-21T16:02:14Z")

</div>

Is there an empty polymorphic variant type? Since the syntax \[\>\] means a polymorphic variant that can have any constructors, it would seem natural for \[\<\] to mean a polymorphic variant that can have no constructors (hen…

---

## [How can my code know my program's version?](https://discuss.ocaml.org/t/how-can-my-code-know-my-programs-version/17980)

<div class="topic-metadata">

**Author:** [@user1](https://discuss.ocaml.org/u/user1)\
**Replies:** 9\
**Last updated:** [April 13, 2026, 11:18am UTC](https://discuss.ocaml.org/t/how-can-my-code-know-my-programs-version/17980 "2026-04-13T11:18:06Z")

</div>

In an example in the Cmdliner tutorial tutorial (cmdliner.tutorial) I see the promising line Cmd.make (Cmd.info "TODO" ~version:"%%VERSION%%") @@ ... so I guess there should be some kind of preprocessing to replace…

---

## [Which data type to use as an input channel for a parser?](https://discuss.ocaml.org/t/which-data-type-to-use-as-an-input-channel-for-a-parser/17967)

<div class="topic-metadata">

**Author:** [@jbe](https://discuss.ocaml.org/u/jbe)\
**Replies:** 6\
**Last updated:** [April 11, 2026, 3:18pm UTC](https://discuss.ocaml.org/t/which-data-type-to-use-as-an-input-channel-for-a-parser/17967 "2026-04-11T15:18:48Z")

</div>

I have an API for which I would like to add a function that parses a specific data structure from its text representation. I currently want to process the input on a per-line basis, but this is just how I currently do i…

---

## [Missing bindings to lwt-graphics?](https://discuss.ocaml.org/t/missing-bindings-to-lwt-graphics/17938)

<div class="topic-metadata">

**Author:** [@GirardR1006](https://discuss.ocaml.org/u/GirardR1006)\
**Replies:** 1\
**Last updated:** [April 1, 2026, 1:53pm UTC](https://discuss.ocaml.org/t/missing-bindings-to-lwt-graphics/17938 "2026-04-01T13:53:56Z")

</div>

Hello, I am currently trying to reproduce this tutorial on writing a simple in-browser application using js\_of\_ocaml, but compilation fails when trying to find the \`js\_of\_ocaml-lwt.graphics\` library. It is seems that in…

---

## [Is there any way to capture the stdout & stderr output of the current process?](https://discuss.ocaml.org/t/is-there-any-way-to-capture-the-stdout-stderr-output-of-the-current-process/17415)

<div class="topic-metadata">

**Author:** [@ahelwer](https://discuss.ocaml.org/u/ahelwer)\
**Replies:** 8\
**Last updated:** [April 1, 2026, 12:20pm UTC](https://discuss.ocaml.org/t/is-there-any-way-to-capture-the-stdout-stderr-output-of-the-current-process/17415 "2026-04-01T12:20:56Z")

</div>

One of the more common side-effects for functions to have is writing output to stdout or stderr. This poses a problem when writing unit tests in OUnit2, both because having a whole bunch of output printed to the console …

---

## [\[ANN\] CS6868 Concurrent Programming -- Course Materials](https://discuss.ocaml.org/t/ann-cs6868-concurrent-programming-course-materials/17932)

<div class="topic-metadata">

**Author:** [@kayceesrk](https://discuss.ocaml.org/u/kayceesrk)\
**Replies:** 0\
**Last updated:** [March 28, 2026, 5:10am UTC](https://discuss.ocaml.org/t/ann-cs6868-concurrent-programming-course-materials/17932 "2026-03-28T05:10:35Z")

</div>

I’m currently teaching a course called “CS6868: Concurrent Programming” at IIT Madras. The goal of the course is to teach concurrent and parallel programming using OCaml 5, and then introduce OxCaml for safe and fast par…

---

## [Promoting a function to a deep continuation](https://discuss.ocaml.org/t/promoting-a-function-to-a-deep-continuation/17924)

<div class="topic-metadata">

**Author:** [@shapeofdreams123](https://discuss.ocaml.org/u/shapeofdreams123)\
**Replies:** 3\
**Last updated:** [March 27, 2026, 9:53pm UTC](https://discuss.ocaml.org/t/promoting-a-function-to-a-deep-continuation/17924 "2026-03-27T21:53:43Z")

</div>

The example for deep handlers in the docs has this following paragraph: The computation f may also perform effects. If f performs the Yield effect, the current task is suspended (inserted into the queue of ready tasks)…

---

## [Error handling regarding dimension mismatch: Using invalid\_arg?](https://discuss.ocaml.org/t/error-handling-regarding-dimension-mismatch-using-invalid-arg/17923)

<div class="topic-metadata">

**Author:** [@jbe](https://discuss.ocaml.org/u/jbe)\
**Replies:** 8\
**Last updated:** [March 25, 2026, 7:04pm UTC](https://discuss.ocaml.org/t/error-handling-regarding-dimension-mismatch-using-invalid-arg/17923 "2026-03-25T19:04:12Z")

</div>

I’ve recently been working with vectors (using immutable arrays). At several places in my code, I would like to ensure that the dimensions of my vectors match. Continuing the discussion from Partial match: Style advice: …

---

## [Notty+Unix socket in separate domains: UI update stop for some reason](https://discuss.ocaml.org/t/notty-unix-socket-in-separate-domains-ui-update-stop-for-some-reason/17911)

<div class="topic-metadata">

**Author:** [@Kakadu](https://discuss.ocaml.org/u/Kakadu)\
**Replies:** 2\
**Last updated:** [March 24, 2026, 11:04am UTC](https://discuss.ocaml.org/t/notty-unix-socket-in-separate-domains-ui-update-stop-for-some-reason/17911 "2026-03-24T11:04:57Z")

</div>

This is my first time experimenting with Notty, and the goal is to implement a monitoring systems that receives something via Unix socket and paints it. I used this notty demo because it uses timer to periodically upda…

---

## [Ocaml exceptions](https://discuss.ocaml.org/t/ocaml-exceptions/17918)

<div class="topic-metadata">

**Author:** [@Vinod](https://discuss.ocaml.org/u/Vinod)\
**Replies:** 4\
**Last updated:** [March 24, 2026, 9:01am UTC](https://discuss.ocaml.org/t/ocaml-exceptions/17918 "2026-03-24T09:01:38Z")

</div>

I have a doubt in exceptions. I define a function foo as follows: let bar \_ = raise (MyException “Hello”);; let foo n = bar (n+1);; The following code compiles without error try foo 5 with MyException h → print\_end…

---

## [Lox interpreter - beginner's attempt](https://discuss.ocaml.org/t/lox-interpreter-beginners-attempt/17913)

<div class="topic-metadata">

**Author:** [@Jacek\_Podkanski](https://discuss.ocaml.org/u/Jacek_Podkanski)\
**Replies:** 0\
**Last updated:** [March 20, 2026, 12:29am UTC](https://discuss.ocaml.org/t/lox-interpreter-beginners-attempt/17913 "2026-03-20T00:29:58Z")

</div>

Some people tried to implement lox interpreter based on the book Crafting Interpreters. This is my attempt. I had lots of aaargh! moment to reach this point. https://gitlab.com/bigos/simple\_interpreter/-/blob/main/lib/…

---

## [Bounds of Random.float (exclusive vs inclusive)](https://discuss.ocaml.org/t/bounds-of-random-float-exclusive-vs-inclusive/17895)

<div class="topic-metadata">

**Author:** [@jbe](https://discuss.ocaml.org/u/jbe)\
**Replies:** 14\
**Last updated:** [March 19, 2026, 4:22pm UTC](https://discuss.ocaml.org/t/bounds-of-random-float-exclusive-vs-inclusive/17895 "2026-03-19T16:22:16Z")

</div>

I would like to create random floats following a Gaussian (normal) distribution with μ=0 and σ=1. I’m using the Box-Muller transform, and this is my source code: let rec gaussian\_floats : unit -\> float Seq.t = let pi…

---

## [Redundant API in stdlib, which to choose?](https://discuss.ocaml.org/t/redundant-api-in-stdlib-which-to-choose/17903)

<div class="topic-metadata">

**Author:** [@jbe](https://discuss.ocaml.org/u/jbe)\
**Replies:** 5\
**Last updated:** [March 19, 2026, 11:09am UTC](https://discuss.ocaml.org/t/redundant-api-in-stdlib-which-to-choose/17903 "2026-03-19T11:09:26Z")

</div>

I recently come across some two redundant function pairs (aliases) in stdlib, specifically those two: Seq.return vs Seq.singleton List.concat vs List.flatten I know I can use either, and none of those is marked deprec…

---

## [Trying to understand list pattern matching and the \`::\` operator](https://discuss.ocaml.org/t/trying-to-understand-list-pattern-matching-and-the-operator/17905)

<div class="topic-metadata">

**Author:** [@jackwsmth](https://discuss.ocaml.org/u/jackwsmth)\
**Replies:** 7\
**Last updated:** [March 18, 2026, 8:03pm UTC](https://discuss.ocaml.org/t/trying-to-understand-list-pattern-matching-and-the-operator/17905 "2026-03-18T20:03:20Z")

</div>

Hi everyone, I’ve been working through the OCaml CS3110 book, and I’m struggling to wrap my head around list pattern matching. In the examples used, it shows how you can use the cons operator (::) to prepend elements to…

---

## [How to write custom runtime for run bytecode on embedded platforms (like PSP) i.e. VM?](https://discuss.ocaml.org/t/how-to-write-custom-runtime-for-run-bytecode-on-embedded-platforms-like-psp-i-e-vm/17906)

<div class="topic-metadata">

**Author:** [@dx3mod](https://discuss.ocaml.org/u/dx3mod)\
**Replies:** 3\
**Last updated:** [March 18, 2026, 6:58pm UTC](https://discuss.ocaml.org/t/how-to-write-custom-runtime-for-run-bytecode-on-embedded-platforms-like-psp-i-e-vm/17906 "2026-03-18T18:58:06Z")

</div>

What should I do and where should I start? It’s not a question of profit, it’s just for fun. Can OCaml run on the PSP platform for game development or other platforms without a large Unix environment?

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

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