# Generating callgraph from elm code

**URL:** <https://discourse.elm-lang.org/t/generating-callgraph-from-elm-code/7113>\
**Category:** Learn\
**Created:** [March 17, 2021, 2:39pm UTC](https://discourse.elm-lang.org/t/generating-callgraph-from-elm-code/7113 "2021-03-17T14:39:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deimos](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/deimos/32/2359_2.png) [@Deimos](https://discourse.elm-lang.org/u/Deimos)\
**Post date:** [March 17, 2021, 2:39pm UTC](https://discourse.elm-lang.org/t/generating-callgraph-from-elm-code/7113/1 "2021-03-17T14:39:49Z")

</div>

Is there any way to generate the callgraph of a set of elm files? I imagine it could be extracted from the parse step done in elm-analyze or elm-format, but I’m not sure where to start…

---

<div class="post-metadata">

**Author:** ![klaftertief](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/klaftertief/32/5338_2.png) [@klaftertief](https://discourse.elm-lang.org/u/klaftertief)\
**Post date:** [March 17, 2021, 3:11pm UTC](https://discourse.elm-lang.org/t/generating-callgraph-from-elm-code/7113/2 "2021-03-17T15:11:56Z")

</div>

I believe you will have the best luck with elm-review. It is kind of the successor of elm-analyse and is designed to support custom rules. Maybe [Review.Rule - elm-review 2.3.11](https://package.elm-lang.org/packages/jfmengels/elm-review/2.3.11/Review-Rule) helps to get you started.

---

<div class="post-metadata">

**Author:** ![Deimos](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/deimos/32/2359_2.png) [@Deimos](https://discourse.elm-lang.org/u/Deimos)\
**Post date:** [March 17, 2021, 3:31pm UTC](https://discourse.elm-lang.org/t/generating-callgraph-from-elm-code/7113/3 "2021-03-17T15:31:30Z")

</div>

Thanks! Looking at the links in elm-review I found elm-syntax and then elm-xref: I think I have enough to get started.

---

<div class="post-metadata">

**Author:** ![klaftertief](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/klaftertief/32/5338_2.png) [@klaftertief](https://discourse.elm-lang.org/u/klaftertief)\
**Post date:** [March 17, 2021, 3:54pm UTC](https://discourse.elm-lang.org/t/generating-callgraph-from-elm-code/7113/4 "2021-03-17T15:54:56Z")

</div>

Ah, yes, I forgot about `elm-xref`. Thanks for the reminder. 🙂

---

<div class="post-metadata">

**Author:** ![jfmengels](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/jfmengels/32/3124_2.png) [@jfmengels](https://discourse.elm-lang.org/u/jfmengels)\
**Post date:** [March 17, 2021, 5:19pm UTC](https://discourse.elm-lang.org/t/generating-callgraph-from-elm-code/7113/5 "2021-03-17T17:19:03Z")

</div>

If you are looking for a graph of module imports, then `elm-analyse` already does that. If you run it with `--serve`, somewhere in the UI you will be able to find the call graph represented as a DOT file, for which you can find an online interpreter which will draw it for you. (sorry for being fuzzy about the details but I’m having difficulties running it right now 🤔 )

---

<div class="post-metadata">

**Author:** ![Deimos](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/deimos/32/2359_2.png) [@Deimos](https://discourse.elm-lang.org/u/Deimos)\
**Post date:** [March 17, 2021, 5:37pm UTC](https://discourse.elm-lang.org/t/generating-callgraph-from-elm-code/7113/6 "2021-03-17T17:37:46Z")

</div>

Thanks. Unfortunately, I’m not just looking for the call graph at the module level…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [March 27, 2021, 5:38pm UTC](https://discourse.elm-lang.org/t/generating-callgraph-from-elm-code/7113/7 "2021-03-27T17:38:37Z")

</div>

Closed on March 27, 2021, 5:38pm UTC

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
