Re:Semantic Clojure Formatting
by UrsaMedius on Tuesday December 08, 2020 @02:42AM
(#25342911)
You might be interested in Unison, where you edit code in text but let the manager/runtime handle the storage. It changes how you need to work with VCS quite a lot. https://www.unisonweb.org/
Also Dhall, a configuration language, generates hashes for semantics so if you refactor something you can check that the hash is unchanged to know that the function is unchanged. https://dhall-lang.org/
Re:Semantic Clojure Formatting
by fiddlerwoaroof on Tuesday December 08, 2020 @02:40AM
(#25342889)
There are various tools for this: I believe one of the interns at Jane Street wrote a tool to diff s-expressions, and similar tools exist for lisp source code. Ultimately, the issue is that tooling is mostly made to be programming-language independent, which makes it hard for this sort of tooling to succeed
Re:Semantic Clojure Formatting
by ulrikrasmussen on Tuesday December 08, 2020 @02:57AM
(#25342993)
I think making a tool like that language independent is impossible. You have to start by making it a diff tool just for tree structured data (diff tools today are special cases of this as they operate on list based data). You then need to extend it to work on specific languages by diffing "modulo equations", e.g. in Haskell two top-level definitions are allowed to commute, so `x = e; y = f` should be considered identical to `y = f; x = e`.
But I think that's fine. The diff tool should use the most specific diff mode that it knows is safe, and fall back to the "free diff" of tree structured data when working on an unknown language.
Re:Semantic Clojure Formatting
by fiddlerwoaroof on Tuesday December 08, 2020 @03:04AM
(#25343028)
I looked into using tree-sitter as a bar for this once: parse code into an AST of sorts and then use the ast to define the diff boundaries. Didn’t think through all the problems, though
Given their simple syntax, one of the lisps seem to be the best poised to drive this change.