frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Improvements to OCaml code editing: the basics of a refactor engine

https://tarides.com/blog/2025-08-20-internship-report-refactoring-tools-coming-to-merlin/
99•nukifw•5mo ago

Comments

panglesd•5mo ago
Very cool!

Does it replace identical expressions in the same scope? Like:

    let tau = 3.14 +. 3.14
becomes

    let pi = 3.14
    let tau = pi +. pi
?

EDIT: Or even crazier with function:

    let _ = (x + 1) + (y + 1)
becomes

    let plus_one a = a + 1
    let _ = (plus_one x) + (plus_one y)

(I ask this just out of curiosity. Even the "simpler" version is very impressive!)
nukifw•5mo ago
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
greener_grass•5mo ago
LLM generated variable names would be nice!
ethan_smith•5mo ago
Most refactoring engines don't automatically replace all identical expressions by default since it can change semantics (especially with side effects), but they typically offer a separate "introduce and replace all occurrences" option that you can explicitly choose.
lemonwaterlime•5mo ago
I’ve been working on similar refactoring and grepping utility functions for vim, though mine are meant to work in any language.

The most recent one I’ve made runs 'git grep' on the word under cursor or on the visual selection and puts everything into a quick fix list.

Since it is generic, it works on any phrases as well, and helps me find prose snippets and phrases in docs or other writings.

mhitza•5mo ago
Extract expression is such a common refactoring, happy to see support for it. I'm even more curious to see now if there are going to be more advanced refactoring possible. A List.map, to for loop, and back refactoring would be such a great thing to have in how I program.

Only thing that would go on my OCD nerve, is the lack of an empty newline when the show_markup function is extracted. Kind of "common sense" when writing top level bindings to leave some breathing room between them.

nukifw•5mo ago
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!

shortrounddev2•5mo ago
I feel that Ocaml could really use better VSCode integration more than literally anything else, but the community seems completely oriented around emacs
nukifw•5mo ago
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 :)

shortrounddev2•5mo ago
The LSP features, in my experience, work very well in VScode, no shade there. But debugging features like breakpoints still seem to be experimental? Whenever I ask others about it online they usually try to tell me that print debugging is superior anyways
StopDisinfo910•5mo ago
My experience is that everything goes into Merlin, which is Ocaml tool for analysis and refactoring, and is then added to editor from there.

Here significant work was done to properly bridge the gap between Merlin and the LSP server so it should work fine in VSCode.

Generally speaking, the Ocaml community seems to spend a lot of time getting VSCode to work.

Syzygies•5mo ago
Tarides has an OCaml focus. Elsewhere on their site, with an interesting omission:

"Examples of functional programming languages include OCaml, Erlang, Clojure, Haskell, Scala, and Common Lisp."

F# and OCaml are close cousins, and for me F# is even cleaner syntax and twice as fast (M4 Mac Studio).

It was a struggle for me to overcome my partisan preference for OCaml.

StopDisinfo910•5mo ago
F# started as an Ocaml port to the CLR. In the end, they decided to port a subset of the language so you get mostly the same syntax, no parametrised modules which is a big part of Ocaml but in exchange you can call libraries from other languages using the CLR. Of course, that comes with the issue of being a second class citizen in the .Net family, albeit a very nice second class citizen.

F# have drifted a bit further since but not that much. It’s a nice language but it’s not really comparable to Ocaml at this point. At least, I don’t see many cases where people would have to chose one or the other. I think people know if they want the CLR or not.

Syzygies•5mo ago
I make little use of .NET; my hand-coded atomic queue is faster than .NET work stealing for parallelism, for example. I like the slightly cleaner syntax and twice as fast for my applications.

I'm escaping the black hole of Haskell. If one can code in Chez Scheme, one can code without parametrized modules, as much as I admire them. And there are also F# additions OCaml could admire.

I held back for all of your reasons, and finally caved. I never saw myself in the .NET ecosystem, but prejudices are a funny thing.

StopDisinfo910•5mo ago
> prejudices are a funny thing

I don’t think people have prejudices here. Ocaml is Ocaml and F# is F#.

If your point is that people using OCaml should instead use F#, I vehemently disagree. That would be losing most of what makes Ocaml actually Ocaml.

Still F# is a nice language. F# without using .Net library I don’t see the point however. It’s the most interesting part of the language.

amelius•5mo ago
Anyone tried large codebase refactorings using AI?
MutedEstate45•5mo ago
Great work! Definitely feels a lot more technical than the typical internship project.

OpenCiv3: Open-source, cross-platform reimagining of Civilization III

https://openciv3.org/
399•klaussilveira•5h ago•89 comments

The Waymo World Model

https://waymo.com/blog/2026/02/the-waymo-world-model-a-new-frontier-for-autonomous-driving-simula...
755•xnx•10h ago•461 comments

Show HN: Look Ma, No Linux: Shell, App Installer, Vi, Cc on ESP32-S3 / BreezyBox

https://github.com/valdanylchuk/breezydemo
132•isitcontent•5h ago•14 comments

Monty: A minimal, secure Python interpreter written in Rust for use by AI

https://github.com/pydantic/monty
123•dmpetrov•5h ago•53 comments

Why I Joined OpenAI

https://www.brendangregg.com/blog/2026-02-07/why-i-joined-openai.html
20•SerCe•1h ago•15 comments

Dark Alley Mathematics

https://blog.szczepan.org/blog/three-points/
33•quibono•4d ago•2 comments

Show HN: I spent 4 years building a UI design tool with only the features I use

https://vecti.com
235•vecti•7h ago•114 comments

A century of hair samples proves leaded gas ban worked

https://arstechnica.com/science/2026/02/a-century-of-hair-samples-proves-leaded-gas-ban-worked/
60•jnord•3d ago•3 comments

Microsoft open-sources LiteBox, a security-focused library OS

https://github.com/microsoft/litebox
302•aktau•11h ago•152 comments

Sheldon Brown's Bicycle Technical Info

https://www.sheldonbrown.com/
305•ostacke•11h ago•82 comments

Show HN: If you lose your memory, how to regain access to your computer?

https://eljojo.github.io/rememory/
162•eljojo•8h ago•122 comments

Hackers (1995) Animated Experience

https://hackers-1995.vercel.app/
381•todsacerdoti•13h ago•215 comments

An Update on Heroku

https://www.heroku.com/blog/an-update-on-heroku/
310•lstoll•11h ago•230 comments

Show HN: R3forth, a ColorForth-inspired language with a tiny VM

https://github.com/phreda4/r3
45•phreda4•4h ago•7 comments

I spent 5 years in DevOps – Solutions engineering gave me what I was missing

https://infisical.com/blog/devops-to-solutions-engineering
102•vmatsiiako•10h ago•34 comments

How to effectively write quality code with AI

https://heidenstedt.org/posts/2026/how-to-effectively-write-quality-code-with-ai/
173•i5heu•8h ago•128 comments

Learning from context is harder than we thought

https://hy.tencent.com/research/100025?langVersion=en
139•limoce•3d ago•76 comments

Understanding Neural Network, Visually

https://visualrambling.space/neural-network/
225•surprisetalk•3d ago•30 comments

I now assume that all ads on Apple news are scams

https://kirkville.com/i-now-assume-that-all-ads-on-apple-news-are-scams/
963•cdrnsf•14h ago•413 comments

Introducing the Developer Knowledge API and MCP Server

https://developers.googleblog.com/introducing-the-developer-knowledge-api-and-mcp-server/
10•gfortaine•3h ago•0 comments

FORTH? Really!?

https://rescrv.net/w/2026/02/06/associative
37•rescrv•13h ago•17 comments

PC Floppy Copy Protection: Vault Prolok

https://martypc.blogspot.com/2024/09/pc-floppy-copy-protection-vault-prolok.html
7•kmm•4d ago•0 comments

Evaluating and mitigating the growing risk of LLM-discovered 0-days

https://red.anthropic.com/2026/zero-days/
33•lebovic•1d ago•11 comments

Show HN: Smooth CLI – Token-efficient browser for AI agents

https://docs.smooth.sh/cli/overview
76•antves•1d ago•56 comments

The Oklahoma Architect Who Turned Kitsch into Art

https://www.bloomberg.com/news/features/2026-01-31/oklahoma-architect-bruce-goff-s-wild-home-desi...
17•MarlonPro•3d ago•2 comments

I'm going to cure my girlfriend's brain tumor

https://andrewjrod.substack.com/p/im-going-to-cure-my-girlfriends-brain
31•ray__•2h ago•7 comments

Show HN: Slack CLI for Agents

https://github.com/stablyai/agent-slack
38•nwparker•1d ago•8 comments

Claude Composer

https://www.josh.ing/blog/claude-composer
98•coloneltcb•2d ago•68 comments

Evolution of car door handles over the decades

https://newatlas.com/automotive/evolution-car-door-handle/
38•andsoitis•3d ago•61 comments

Planetary Roller Screws

https://www.humanityslastmachine.com/#planetary-roller-screws
34•everlier•3d ago•6 comments