package ocamlmig
OCaml source code rewriting tool
Install
Dune Dependency
Authors
Maintainers
Sources
ocamlmig-5.3-20250429.tbz
sha256=51e13b4a6bbc86eb2470a5a33087714a8c0895b05d912e1706e7a95c6b1b11d3
sha512=d6b5b2b0af6b5976dac08c3c821faa1a5690ce56485cc29ac427046de2a4c446c6212bbf4ef5821503d57163634ec5ad78b3d4b452359096a23a6f08b5e9c9e1
doc/README.html
ocamlmig is a command line tool for rewriting ocaml source code with access to scope and type information.
As a simple example of what it can do, let's say an opam-installed library A provides this interface:
val new_name : int -> int
val old_name : int -> int
[@@migrate { repl = Rel.new_name }]
and your repository contains a file b.ml:
let _ = A.old_name 1
then you could do:
$ git diff b.ml
$ ocamlmig migrate -w
$ git diff b.ml
-let _ = A.old_name 1
+let _ = A.new_name 1
Examples of real rewrites:
- Renaming operators (not trivial because the operators change precedence)
- Switching code using both Stdlib and Core to mostly Core
- Switching code using Cmdliner's
$
tolet+
, in three parts: switch to let+ proper (commit 2), removing tags (commit 3), and inlining flag terms (last commit). ocamlmig also checks that variables in moved code keep pointing to the same value. ocamlmig also checks that variables in moved code keep pointing to the same value.
If that piqued your interest, you can find more information about what ocamlmig does, and using it.
This is work in progress, so many things are only partially implemented, but the existing functionality as is should still be interesting.
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>