jonascarpay / calligraphy

haskell source code visualizer
BSD 3-Clause "New" or "Revised" License
97 stars 13 forks source link

--toplevel-only #29

Open kazu-yamamoto opened 1 year ago

kazu-yamamoto commented 1 year ago

First of all, thank you for creating a great tool!

I would like to have call graphs of top level functions only where all non-exports are included but local-bindings under where are hidden. Is such a feature technically possible?

jonascarpay commented 1 year ago

That's done by the --collapse family of options, in your case specifically --collapse-values. Or do I misunderstand what you're looking for?

Maybe they need better documentation/help text...

kazu-yamamoto commented 1 year ago

I tried --collapse-values but it displays local functions under where in a top-level function. It is vocal a bit for me. I would like to have a call graph with top-level functions only.

kazu-yamamoto commented 1 year ago

Currently, to get such a graph, I need to modify a module with its export list removed and use --exports-only.

jonascarpay commented 1 year ago

I tried --collapse-values but it displays local functions under where in a top-level function. It is vocal a bit for me. I would like to have a call graph with top-level functions only.

Oh, that's odd, I don't think this should happen! Is there any chance you can give me a MWE for this?

kazu-yamamoto commented 1 year ago

What does "MWE" stand for?

jonascarpay commented 1 year ago

So, just to confirm, with --collapse-values you don't get this behavior (i.e. showing non-exported top-level bindings, but hiding where-clauses)?

module KazuTest () where

foo = bar
  where
    bar = foo

calligraphy KazuTest --collapse-values --stdout-mermaid:

flowchart TD
    node_0[foo]
    style node_0 stroke-dasharray: 5 5
    classDef default fill-opacity:0,stroke:#777;

What does "MWE" stand for?

Oh sorry, minimal working example. If indeed you're getting different behavior than the example above, a small example that reproduces the bug.

kazu-yamamoto commented 1 year ago

In this case, I got the same result: foo only.

jonascarpay commented 1 year ago

Sorry, my question should have been clearer maybe. You say that with --collapse-values, "it displays local functions under where in a top-level function". Can you give an example of that? Because as I show here, that shouldn't be happening.

kazu-yamamoto commented 1 year ago

The example which I hit upon is huge. So, I'm trying to create a small example now.