jaredly / jaredly/example-reason-codemod

Detect a function of a given module?

Open
#1 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
OCaml
Stars
3
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Thanks for creating these codemod utils and example! 🙂 Really cool.

I'm exploring if I could use this codemod for the migrations of BuckleScript `Js` modules proposed in https://github.com/BuckleScript/bucklescript/issues/2975. I wonder how I could approach the detection of usages of some specific functions in `Js.X` modules:

If I use syntactic analysis (e.g. use `Pexp_ident` to match against the function names) it might not be effective in all cases, for example the function can be called with `Js.Array.map` or just `map` if the `Js.Array` module has been opened before.

There is `getExprType` which is awesome but it just works at the type level, so I wouldn't know which function has been called, only the type of the expression.

Is there an approach that I'm missing to do this kind of detection in an accurate way?

Contributor guide

No contributing guide indexed for this repository

Research direction

Review the codemod utils and example, then investigate how Pexp_ident and getExprType handle calls such as Js.Array.map and an opened-module map. Compare whether the available syntax and type information can identify the called function accurately. Done means documenting a reliable detection approach or the limitation that prevents it.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.