nukifw
nukifw on Hacker News
Posted by
nukifw on Thursday October 01, 2026 @12:30PM
from the grim.cargocut.org dept.
Posted by
nukifw on Monday June 15, 2026 @11:32AM
from the xvw.lol dept.
Posted by
nukifw on Thursday November 27, 2025 @08:40AM
from the tarides.com dept.
Posted by
nukifw on Tuesday October 28, 2025 @01:40PM
from the xvw.lol dept.
In the `show_content` example, using first class modules: `module H : ...`. The type need to be specified and since module composition is hard, it leads to very verbose solution
We try to invest equal time between the OCaml platform (on VSCode) and OCaml-eglot (for Emacs). In fact, I find the VSCode extension to be rich (and generally iso-features with Emacs mode).
However, I (as maintainer of OCaml-eglot) find Emacs easier to extend (the VSCode extension is surprisingly complex when you stray from the beaten path), which seemed perfect for incubating an experimental feature. Furthermore, as mentioned at the end of the article, the feature can also be invoked from a code action, which makes it de facto callable from VSCode once the various PRs have been merged :)
For the first point, you are right. We start by a common (but very useful) feature. Since OCaml allows an infinite level of nesting (and different kind of structure item) it was still a bit of a challenge, mostly for finding the right UX.
For the second point we delay the aeration convention to the formatter (ocamlformat). It can be configure in a different way :)
Thanks for your feedback!
PRs are mentioned at the end of articles. It is possible to `pin` repositories locally on their different branches to experiment with them locally!
Nop, for the moment, we try to not "infer user usages"!
But if you extract an expression with variable, there will be, obviously, not be repeated:
let tau =
let pi = 3.14 in
pi + pi
if we extract `pi + pi` it will lead (if you do not give any concrete name) to the following code:
let fun_name1 pi =
pi + pi
let tau =
let pi = 3.14 in
fun_name1 pi
Posted by
nukifw on Wednesday August 20, 2025 @09:37AM
from the tarides.com dept.
Posted by
nukifw on Monday August 18, 2025 @10:17AM
from the gr-im.github.io dept.
Ok! (BTW, thanks for the interaction!)
Yes and my point was, when you want what you present in the first comment, quoting my post, you have tools for that, available in OCaml. But there is cases, when you do not want to treat each branch of your constructors "as a type", when the encoding of visitors is just rough. This is why I think it is nice to have sum type, to complete product type. So i am not sure why we are arguing :)
- You can use GADTs (
https://ocaml.org/manual/5.2/gadts-tutorial.html) and indexes to give a concrete type to every constructors:
```ocaml
type _ treated_as =
| Int : int -> int treated_as
| Float : float -> float treated_as
let f (Int x) = x + 1 (* val f : int treated_as -> int *)
```
- You can use the structurale nature of polymorphic variants (
https://ocaml.org/manual/5.1/polyvariant.html)
```ocaml
let f = function
| `Foo x -> string_of_int (x + 1)
| `Bar x -> x ^ "Hello"
(* val f : [< `Foo of int | `Bar of string] -> string` *)
let g = function
| `Foo _ -> ()
| _ -> ()
(* val g : [> `Foo of 'a ] -> unit *)
```
(Notice the difference between `>` and `<` in the signature?)
And since OCaml has also an object model, you can also encoding sum and sealing using modules (and private type abreviation).
Sorry, I never used ReasonML so I don't see any advantage of using ReasonML except it had the time to die twice in 4 years :)
Usually we speaking only about sum and product (because article usually refers to ADT, so Algebraic Data type). A function is not really Data, so it is not included. But you can use the same tricks (ie: a -> b has arity b^a) to compute the number of potential inhabitant
Package description, but it use its own engine.
And the next milestone of Dune is to become an alternative package manager via Dune package Management, using a store in a "nixish" way.
Yes, the trick is expanded here:
https://libres.uncg.edu/ir/asu/f/Johann_Patricia_2008_Founda... (if you have `Eq a b = Refl : a a eq` you should be able to encode every useful GADTs. But having a compiler support is nice for specifics reason like being able to "try" to detect unreachable cases in match branches for examples.
In the specific case of OCaml, this is also possible using indexing and GADTs or polymorphic variants. But generally, referencing as its own type serves different purposes. From my point of view, distinguishing between sum branches often tends to result in code that is difficult to reason about and difficult to generalise due to concerns about variance and loss of type equality.
Hi! Thank you for your interest (and for potentially reading this).
Yes, F# is a very nice language, however, it seems to me that I am making a somewhat forced comparison between OCaml and F# in the following section: https://xvw.lol/en/articles/why-ocaml.html#ocaml-and-f
Posted by
nukifw on Wednesday August 13, 2025 @02:05PM
from the xvw.lol dept.
Yes, as I try to explain in the article (voluntary written in the sense of an archeologic exploration) the main point of frustration is the lack of explanation. Trying to deduce everything was hard, when I was 10 :)
Posted by
nukifw on Friday January 17, 2025 @01:02PM
from the github.com dept.
Posted by
nukifw on Friday April 15, 2022 @06:01AM
from the blog.osau.re dept.