# \#stdlib

**URL:** https://discuss.ocaml.org/tag/stdlib/169.md

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

---

## [Run-time types: uses and wants](https://discuss.ocaml.org/t/run-time-types-uses-and-wants/18085)

<div class="topic-metadata">

**Author:** [@raphael-proust](https://discuss.ocaml.org/u/raphael-proust)\
**Replies:** 44\
**Last updated:** [August 28, 2026, 4:37pm UTC](https://discuss.ocaml.org/t/run-time-types-uses-and-wants/18085 "2026-08-28T16:37:16Z")

</div>

This is an informal survey to assess the interest in run-time types from various users. If you are not sure what this is about check lexifi’s talk at funocaml and specifically the type reflection section (timecode on the…

---

## [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…

---

## [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…

---

## [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; } …

---

## [Should \`Stdlib.Float.min\_float\` be negative?](https://discuss.ocaml.org/t/should-stdlib-float-min-float-be-negative/17631)

<div class="topic-metadata">

**Author:** [@yawaramin](https://discuss.ocaml.org/u/yawaramin)\
**Replies:** 2\
**Last updated:** [December 23, 2025, 10:08pm UTC](https://discuss.ocaml.org/t/should-stdlib-float-min-float-be-negative/17631 "2025-12-23T22:08:35Z")

</div>

Float.min\_float is a positive number: # Float.min\_float;; - : float = 2.22507385850720138e-308 This is a bit surprising to me. Shouldn’t it be a negative number?

---

## [Why Lean 4 replaced OCaml as my Primary Language](https://discuss.ocaml.org/t/why-lean-4-replaced-ocaml-as-my-primary-language/17109)

<div class="topic-metadata">

**Author:** [@shonfeder](https://discuss.ocaml.org/u/shonfeder)\
**Replies:** 49\
**Last updated:** [October 15, 2025, 1:39pm UTC](https://discuss.ocaml.org/t/why-lean-4-replaced-ocaml-as-my-primary-language/17109 "2025-10-15T13:39:50Z")

</div>

Why Lean 4 replaced OCaml as my Primary Language

---

## [Stdlib vs Base in 2025 (beginner)](https://discuss.ocaml.org/t/stdlib-vs-base-in-2025-beginner/16626)

<div class="topic-metadata">

**Author:** [@emiel](https://discuss.ocaml.org/u/emiel)\
**Replies:** 4\
**Last updated:** [May 9, 2025, 8:45am UTC](https://discuss.ocaml.org/t/stdlib-vs-base-in-2025-beginner/16626 "2025-05-09T08:45:46Z")

</div>

Hello. I’ve restarted my OCaml learning journey and am working on some exercises. One source I’m using is Exercism, which defaults to using Base for exercises. I’m reading OCaml From the Very Beginning and OCaml Programm…

---

## [More/better two lists scanning?](https://discuss.ocaml.org/t/more-better-two-lists-scanning/16602)

<div class="topic-metadata">

**Author:** [@SpiceGuid](https://discuss.ocaml.org/u/SpiceGuid)\
**Replies:** 5\
**Last updated:** [May 6, 2025, 2:36pm UTC](https://discuss.ocaml.org/t/more-better-two-lists-scanning/16602 "2025-05-06T14:36:00Z")

</div>

When scanning two lists i use : val exists2 : ('a -\> 'b -\> bool) -\> 'a list -\> 'b list -\> bool However if i want to exhibit one adequate pair what i need is : val exists2\_opt : ('a -\> 'b -\> bool) -\> 'a list -\> 'b list…

---

## [A tail-recursive List.flatten in Stdlib?](https://discuss.ocaml.org/t/a-tail-recursive-list-flatten-in-stdlib/15382)

<div class="topic-metadata">

**Author:** [@Chris1](https://discuss.ocaml.org/u/Chris1)\
**Replies:** 7\
**Last updated:** [October 6, 2024, 8:05pm UTC](https://discuss.ocaml.org/t/a-tail-recursive-list-flatten-in-stdlib/15382 "2024-10-06T20:05:05Z")

</div>

I was perusing the OCaml source code for Stdlib.List and noticed that List.flatten is implemented in a non-tail-recursive manner. let rec flatten = function \[\] -\> \[\] | l::r -\> l @ flatten r Is there a compellin…

---

## [Format, how to disable pretty printing?](https://discuss.ocaml.org/t/format-how-to-disable-pretty-printing/14872)

<div class="topic-metadata">

**Author:** [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Replies:** 4\
**Last updated:** [June 28, 2024, 12:11pm UTC](https://discuss.ocaml.org/t/format-how-to-disable-pretty-printing/14872 "2024-06-28T12:11:13Z")

</div>

Is there a way to make sure that for a few lines the pretty printing machinery of Format will not try to interfere with output instructions – basically set it in Printf mode.

---

## [Do you know of \`StdLabels\` and \`MoreLabels\` modules?](https://discuss.ocaml.org/t/do-you-know-of-stdlabels-and-morelabels-modules/14792)

<div class="topic-metadata">

**Author:** [@hyphenrf](https://discuss.ocaml.org/u/hyphenrf)\
**Replies:** 7\
**Last updated:** [June 20, 2024, 9:12pm UTC](https://discuss.ocaml.org/t/do-you-know-of-stdlabels-and-morelabels-modules/14792 "2024-06-20T21:12:21Z")

</div>

Do you use them? If yes, how often? Share your experience with them please. This is related to an open issue, and is my own attempt to gather community responses to help the maintainers gauge the interest in those modul…

---

## [Thread Safety in the Standard Library](https://discuss.ocaml.org/t/thread-safety-in-the-standard-library/14581)

<div class="topic-metadata">

**Author:** [@lindig](https://discuss.ocaml.org/u/lindig)\
**Replies:** 4\
**Last updated:** [May 6, 2024, 8:54am UTC](https://discuss.ocaml.org/t/thread-safety-in-the-standard-library/14581 "2024-05-06T08:54:01Z")

</div>

https://v2.ocaml.org/api/Hashtbl.html: Unsynchronized accesses to a hash table may lead to an invalid hash table state. Thus, concurrent accesses to a hash tables must be synchronized (for instance with a Mutex.t). T…

---

## [Interest in a (mutable) binomial heap in Stdlib](https://discuss.ocaml.org/t/interest-in-a-mutable-binomial-heap-in-stdlib/14665)

<div class="topic-metadata">

**Author:** [@jake-87](https://discuss.ocaml.org/u/jake-87)\
**Replies:** 2\
**Last updated:** [May 20, 2024, 10:20pm UTC](https://discuss.ocaml.org/t/interest-in-a-mutable-binomial-heap-in-stdlib/14665 "2024-05-20T22:20:53Z")

</div>

IMO it’d be fairly useful - batteries has one, but they’re inductive, not array-backed, and immutable. There’s precedent for large-storage datastructures in Hashtbl, which I feel is “morally” similar. They wouldn’t be a…

---

## [Print a rational number in binary format](https://discuss.ocaml.org/t/print-a-rational-number-in-binary-format/13643)

<div class="topic-metadata">

**Author:** [@UnixJunkie](https://discuss.ocaml.org/u/UnixJunkie)\
**Replies:** 2\
**Last updated:** [December 15, 2023, 9:15am UTC](https://discuss.ocaml.org/t/print-a-rational-number-in-binary-format/13643 "2023-12-15T09:15:45Z")

</div>

I have a number x such that 0 \<= x \< 1.0. I would like to print x in binary format. e.g. x=1/1024 prints “0.0000000001” x=1/2 prints “0.1” Am I right that the stdlib’s Printf “only” supports octal, decimal and hexade…

---

## [Why do Hashtbl.find and Map.find take arguments in a different order?](https://discuss.ocaml.org/t/why-do-hashtbl-find-and-map-find-take-arguments-in-a-different-order/12893)

<div class="topic-metadata">

**Author:** [@viritrilbia](https://discuss.ocaml.org/u/viritrilbia)\
**Replies:** 8\
**Last updated:** [August 23, 2023, 9:14pm UTC](https://discuss.ocaml.org/t/why-do-hashtbl-find-and-map-find-take-arguments-in-a-different-order/12893 "2023-08-23T21:14:38Z")

</div>

In Hashtbl.find tbl key the table comes first and the key second. But in Map.Make(Ord).find key map the key comes first and the map second. Why the difference?

---

## [Adding indexed variants of all functions in stdlib](https://discuss.ocaml.org/t/adding-indexed-variants-of-all-functions-in-stdlib/12792)

<div class="topic-metadata">

**Author:** [@glen](https://discuss.ocaml.org/u/glen)\
**Replies:** 6\
**Last updated:** [August 11, 2023, 9:26am UTC](https://discuss.ocaml.org/t/adding-indexed-variants-of-all-functions-in-stdlib/12792 "2023-08-11T09:26:21Z")

</div>

I am thinking of adding index-aware variants of existing functions to the standard library. For instance, List.map has an indexed variant named List.mapi. Currently, only a minority of standard functions for which it wou…

---

## [We don't have sincos in the Stdlib?](https://discuss.ocaml.org/t/we-dont-have-sincos-in-the-stdlib/12756)

<div class="topic-metadata">

**Author:** [@UnixJunkie](https://discuss.ocaml.org/u/UnixJunkie)\
**Replies:** 8\
**Last updated:** [August 7, 2023, 3:14am UTC](https://discuss.ocaml.org/t/we-dont-have-sincos-in-the-stdlib/12756 "2023-08-07T03:14:22Z")

</div>

If I am right, we have sin and cos but not the combination of the two. On modern hardware, I think there are special instructions to compute both at once. Because, sometimes you need both the sin and cos of an angle. T…

---

## [Could the Marshal module from the stdlib support marshal to/from a Char Bigarray?](https://discuss.ocaml.org/t/could-the-marshal-module-from-the-stdlib-support-marshal-to-from-a-char-bigarray/11831)

<div class="topic-metadata">

**Author:** [@UnixJunkie](https://discuss.ocaml.org/u/UnixJunkie)\
**Replies:** 2\
**Last updated:** [April 7, 2023, 1:38am UTC](https://discuss.ocaml.org/t/could-the-marshal-module-from-the-stdlib-support-marshal-to-from-a-char-bigarray/11831 "2023-04-07T01:38:38Z")

</div>

That would be a useful feature, since memmapped bigarrays are the de facto shm on Unix-likes for multi process programs. When marshalling, we will need to be able to pass an offset into the bigarray buffer. The functi…

---

## [\[Q\] Does \`Thread\` module really work?](https://discuss.ocaml.org/t/q-does-thread-module-really-work/11718)

<div class="topic-metadata">

**Author:** [@anzhi0708](https://discuss.ocaml.org/u/anzhi0708)\
**Replies:** 9\
**Last updated:** [March 20, 2023, 10:41am UTC](https://discuss.ocaml.org/t/q-does-thread-module-really-work/11718 "2023-03-20T10:41:49Z")

</div>

Hello guys. I’m both a beginner in OCaml & CS, aka a noob. I wrote this piece of code to test Thread module let () = print\_endline "Hello, World!" let rec fib\_normal (n: int): int = match n with | 0 | 1 -\> n …

---

## [Printing Uchar.t values](https://discuss.ocaml.org/t/printing-uchar-t-values/11344)

<div class="topic-metadata">

**Author:** [@JohnJ](https://discuss.ocaml.org/u/JohnJ)\
**Replies:** 6\
**Last updated:** [February 8, 2023, 11:41am UTC](https://discuss.ocaml.org/t/printing-uchar-t-values/11344 "2023-02-08T11:41:05Z")

</div>

I was recently working with a small project that required decoding and printing UTF-8 characters, and I was surprised to find that there was no simple way to print a Uchar.t value. I’m curious if this is something that t…

---

## [Promises promises.. (making Stdlib.Lazy safe for programs with multiple domains)](https://discuss.ocaml.org/t/promises-promises-making-stdlib-lazy-safe-for-programs-with-multiple-domains/11120)

<div class="topic-metadata">

**Author:** [@jhw](https://discuss.ocaml.org/u/jhw)\
**Replies:** 3\
**Last updated:** [January 5, 2023, 7:08pm UTC](https://discuss.ocaml.org/t/promises-promises-making-stdlib-lazy-safe-for-programs-with-multiple-domains/11120 "2023-01-05T19:08:02Z")

</div>

So Orsetto is pretty old, and I’m currently messing around with a draft project that basically amounts to a complete redesign of its Cf library, adopts some programming patterns I’ve learned in recent years by reading th…

---

## [About maps and NaNs](https://discuss.ocaml.org/t/about-maps-and-nans/10831)

<div class="topic-metadata">

**Author:** [@nobrowser](https://discuss.ocaml.org/u/nobrowser)\
**Replies:** 10\
**Last updated:** [November 25, 2022, 12:15am UTC](https://discuss.ocaml.org/t/about-maps-and-nans/10831 "2022-11-25T00:15:31Z")

</div>

I have just read this blogpost about Golang I am curious what the behavior of the Ocaml Map (and also Hashtbl) module is, in this particular respect. (I know it would be relatively easy to try, so forgive my laziness h…

---

## [Stdlib doc: inconsistent spaces around operators, (==) vs ( == )](https://discuss.ocaml.org/t/stdlib-doc-inconsistent-spaces-around-operators-vs/10072)

<div class="topic-metadata">

**Author:** [@muzimuzhi](https://discuss.ocaml.org/u/muzimuzhi)\
**Replies:** 5\
**Last updated:** [June 29, 2022, 5:34pm UTC](https://discuss.ocaml.org/t/stdlib-doc-inconsistent-spaces-around-operators-vs/10072 "2022-06-29T17:34:43Z")

</div>

On doc page OCaml library : Stdlib, which looks not consistent. Related source lines: ocaml/stdlib.mli at 40113fbc73930b41a7a2df468de18c94feeefdf5 · ocaml/ocaml · GitHub Those spaces were added 12 years ago, by com…

---

## [Should we have a \`String.rev\` in \`Stdlib\`?](https://discuss.ocaml.org/t/should-we-have-a-string-rev-in-stdlib/9187)

<div class="topic-metadata">

**Author:** [@ifazk](https://discuss.ocaml.org/u/ifazk)\
**Replies:** 36\
**Last updated:** [January 25, 2022, 9:56pm UTC](https://discuss.ocaml.org/t/should-we-have-a-string-rev-in-stdlib/9187 "2022-01-25T21:56:34Z")

</div>

There have been several times over the last few weeks when I’ve wanted to reverse small strings, mostly for nicer printf-debugging. Was a reverse function ever part stdlib/pervasives at some point and removed for some re…

---

## [Snake case instead of camel case for \`Stdlib.{In\_,Out\_}channel\` introduced in OCaml 4.14](https://discuss.ocaml.org/t/snake-case-instead-of-camel-case-for-stdlib-in-out-channel-introduced-in-ocaml-4-14/9214)

<div class="topic-metadata">

**Author:** [@thierry-martinez](https://discuss.ocaml.org/u/thierry-martinez)\
**Replies:** 2\
**Last updated:** [January 25, 2022, 1:41pm UTC](https://discuss.ocaml.org/t/snake-case-instead-of-camel-case-for-stdlib-in-out-channel-introduced-in-ocaml-4-14/9214 "2022-01-25T13:41:00Z")

</div>

I am very glad to discover the new Stdlib.{In\_,Out\_}channel introduced in OCaml 4.14. Thank you, folks! Sorry for my remark that is purely bikeshedding, but I had the impression that camel case was usually preferred for…

---

## [How are comparison and arithmetic operators implemented in OCaml standard library?](https://discuss.ocaml.org/t/how-are-comparison-and-arithmetic-operators-implemented-in-ocaml-standard-library/9007)

<div class="topic-metadata">

**Author:** [@ajax2112](https://discuss.ocaml.org/u/ajax2112)\
**Replies:** 10\
**Last updated:** [December 13, 2021, 9:00pm UTC](https://discuss.ocaml.org/t/how-are-comparison-and-arithmetic-operators-implemented-in-ocaml-standard-library/9007 "2021-12-13T21:00:49Z")

</div>

I am looking to implement my own library to replace the OCaml standard library, as I am starting to use the language enough that having things named and implemented the way I find most sensible would be worthwhile. I ha…

---

## [Hint about int vs. int64 converts hexadecimal to decimal notation: bug?](https://discuss.ocaml.org/t/hint-about-int-vs-int64-converts-hexadecimal-to-decimal-notation-bug/8810)

<div class="topic-metadata">

**Author:** [@curiousleo](https://discuss.ocaml.org/u/curiousleo)\
**Replies:** 3\
**Last updated:** [November 14, 2021, 2:01pm UTC](https://discuss.ocaml.org/t/hint-about-int-vs-int64-converts-hexadecimal-to-decimal-notation-bug/8810 "2021-11-14T14:01:15Z")

</div>

I just got this friendly error message: 24 | Int64.(to\_int32 (logand b64 0xFFFFFFFF)) ^^^^^^^^^^ Error: This expression has type int but an expression was expected of type i…

---

## [Bug in Str.full\_split?](https://discuss.ocaml.org/t/bug-in-str-full-split/8254)

<div class="topic-metadata">

**Author:** [@UnixJunkie](https://discuss.ocaml.org/u/UnixJunkie)\
**Replies:** 2\
**Last updated:** [August 5, 2021, 2:47am UTC](https://discuss.ocaml.org/t/bug-in-str-full-split/8254 "2021-08-05T02:47:34Z")

</div>

Hello, I am not sure why this is not working. Is it a bug? In utop: #require "str";; Str.(full\_split (regexp "\[\\\\\]\\\\\[\]") "\[toto\]titi\[tata\]");; - : Str.split\_result list = \[Str.Text "\[toto\]titi\[tata\]"\] Str.(full\_split …

---

## [After so many years, I discover 'Str.bounded\_full\_split regexp str n'](https://discuss.ocaml.org/t/after-so-many-years-i-discover-str-bounded-full-split-regexp-str-n/7838)

<div class="topic-metadata">

**Author:** [@UnixJunkie](https://discuss.ocaml.org/u/UnixJunkie)\
**Replies:** 0\
**Last updated:** [May 11, 2021, 6:04am UTC](https://discuss.ocaml.org/t/after-so-many-years-i-discover-str-bounded-full-split-regexp-str-n/7838 "2021-05-11T06:04:25Z")

</div>

This is so useful and powerful: #require "str";; Str.bounded\_full\_split (Str.regexp "\[()\]") "toto (titi, tata (et tutu)) vont au parc (en courant)" 1024;; - : Str.split\_result list = \[Str.Text "toto "; Str.Delim "("; St…

[Next page](https://discuss.ocaml.org/tag/stdlib/169.md?match_all_tags=true&page=1&tags%5B%5D=stdlib)
