Category "ocaml"

How to disable Error (warning 66): unused open! in dune

As per https://github.com/ocaml/ocaml/pull/1110, OCaml 4.08 and later raises a warning for unused module opens, even when they are opened with open!. This creat

In OCaml, what is the difference between `'a.` and `type a.` and when to use each?

OCaml has several different syntaxes for a polymorphic type annotation : let f : 'a -> 'a = … (* Isn’t this one already polymorphic? (an

Is there a way to obtain a 'reference' to a mutable struct field

So I have a record type with mutable field: type mpoint = { mutable x:int ; mutable y: int };; let apoint = { x=3 ; y=4};; And I have a function that expects a

Values do not match

I am pretty sure I am not squinting hard enough to see where the mismatch is ... but I have been staring at my screen for a long time and thus asking this quest

Is there a concise/inline way to create Set values without explicitly naming their type?

In most language that have parametric / generic types, there is a (type) expression you can write to mean 'Set of something'. E.g. Set<Integer> in Java. S

What are row types? Are they algebraic data types?

I often hear that F# lacks support for OCaml row types, that makes the language more powerful than F#. What are they? Are they algebraic data types, such as su

Dealing with unit in Ocaml

So I have a function r which is supposed to apply a function to every element in the list provided it meets a given predicate, and return that list. i.e. let p

How to use Flambda with dune in ocaml?

I'm doing a project in which I need to optimize my code as much as I can because it takes hours to run with a normal compilation. I was told to use Flambda, but

OCaml explicit type signatures

In Haskell, it is considered good practice to explicitly declare the type signature of your functions, even though it can (usually) be inferred. It seems like t

How does one use pattern matching to check if something is even in OCAML?

I tried: let rec f n = match n with | 0 -> case0 | k -> case1 | (2*k) -> case2;; but didn’t work… https://discuss.ocaml.org/t/how-does

Actually changing text size with OCaml Graphics

I was wondering how to set text size in OCaml. I tried Graphics.set_text_size which should do the deal I guess. But whether I put set_text_size 200 or set_text