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

tarides.com

79 points by nukifw 6 hours ago


mhitza - 4 hours 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.

panglesd - 5 hours 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!)
lemonwaterlime - 4 hours 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.

Syzygies - 4 hours 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.

amelius - 4 hours ago

Anyone tried large codebase refactorings using AI?

shortrounddev2 - 4 hours ago

I feel that Ocaml could really use better VSCode integration more than literally anything else, but the community seems completely oriented around emacs

dionedave - 5 hours ago

[dead]

dionedave - 5 hours ago

[flagged]