My journey on building a reasonable codemod template, Friday 20 of November: How to destruct a piece of ReasonML into a mappable AST to input in the mapper #18
How to destruct a piece of ReasonML into a mappable AST to input in the mapper
I know there is a https://astexplorer.net for Reason but it is not very useful since it actually outputs just a JSON and you can't consume that directly in Reason.
Previous post here
ah yes eme ellie devloper
Just some tips today
How to destruct a piece of ReasonML into a mappable AST to input in the mapper
I know there is a https://astexplorer.net for Reason but it is not very useful since it actually outputs just a JSON and you can't consume that directly in Reason.
Turn Reason into OCaml
Copy that expression and remove the
;;
before giving to the next commandppx_tools/dumpast
and it'll output the AST representationNow remove the weird
==>
and the other one at the bottom=========
and you can convert the rest straight back to Reasonoutput
you can go ahead and remove the
[@implicit_arity]
things from there, they are just metadata used by refmt for disambiguation between the syntaxes.And that's it! That's a totally valid record you can use inside a
default_mapper
in a new pattern match case like hereYeah I inlined the whole thing, I'm that lazy for finding a better way and I never remember how to use multiline strings in bash.
I'm no Bash wizard probably someone can create a one-liner to handle all of that at once or even better.