jonascarpay / calligraphy

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

Fails on some modules :( #2

Closed jumper149 closed 2 years ago

jumper149 commented 2 years ago

Really cool project!


So, I tried this out on my homepage: https://github.com/jumper149/homepage/tree/810d5c1d247b75ed1bc4d9e719698de7db3e1d5e

I went ahead and tried to make sure, that I compile calligraphy with the same compiler.

diff --git a/flake.lock b/flake.lock
index 099266d..3620ed4 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,5 +1,27 @@
 {
   "nodes": {
+    "calligraphy": {
+      "inputs": {
+        "flake-utils": "flake-utils",
+        "nixpkgs": [
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1650916325,
+        "narHash": "sha256-ZSL5QQ5fb9ASQakwiwdpm/t9DDhOOB0gLqnH0DkqWcc=",
+        "owner": "jonascarpay",
+        "repo": "calligraphy",
+        "rev": "779835e818b2bff5344e826b35258e8f592f71f3",
+        "type": "github"
+      },
+      "original": {
+        "owner": "jonascarpay",
+        "ref": "master",
+        "repo": "calligraphy",
+        "type": "github"
+      }
+    },
     "deriving-trans": {
       "inputs": {
         "monad-control-identity": [
@@ -24,6 +46,21 @@
         "type": "github"
       }
     },
+    "flake-utils": {
+      "locked": {
+        "lastModified": 1644229661,
+        "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
     "monad-control-identity": {
       "inputs": {
         "nixpkgs": [
@@ -47,22 +84,23 @@
     },
     "nixpkgs": {
       "locked": {
-        "lastModified": 1649930986,
-        "narHash": "sha256-csbCr9UEgJxgpi1ud4k0rqg1qVS4FLHrhpkLVVgo8dM=",
+        "lastModified": 1649178804,
+        "narHash": "sha256-pQaDCKnQsCXH7YEmNTfL7ElEc31IpTFAQMYAEsyIKY8=",
         "owner": "NixOS",
         "repo": "nixpkgs",
-        "rev": "6361b4941a69395ebf15e6e56b142765fce850f9",
+        "rev": "1b5e91c39bf167275b6227c788cfc12cf0fea5fe",
         "type": "github"
       },
       "original": {
         "owner": "NixOS",
-        "ref": "nixpkgs-unstable",
+        "ref": "1b5e91c39bf167275b6227c788cfc12cf0fea5fe",
         "repo": "nixpkgs",
         "type": "github"
       }
     },
     "root": {
       "inputs": {
+        "calligraphy": "calligraphy",
         "deriving-trans": "deriving-trans",
         "monad-control-identity": "monad-control-identity",
         "nixpkgs": "nixpkgs"
diff --git a/flake.nix b/flake.nix
index 41ff4fb..777df07 100644
--- a/flake.nix
+++ b/flake.nix
@@ -6,7 +6,7 @@
       type = "github";
       owner = "NixOS";
       repo = "nixpkgs";
-      ref = "nixpkgs-unstable";
+      ref = "1b5e91c39bf167275b6227c788cfc12cf0fea5fe";
     };
     monad-control-identity = {
       type = "github";
@@ -23,9 +23,16 @@
       inputs.nixpkgs.follows = "nixpkgs";
       inputs.monad-control-identity.follows = "monad-control-identity";
     };
+    calligraphy = {
+      type = "github";
+      owner = "jonascarpay";
+      repo = "calligraphy";
+      ref = "master";
+      inputs.nixpkgs.follows = "nixpkgs";
+    };
   };

-  outputs = { self, nixpkgs, monad-control-identity, deriving-trans }: {
+  outputs = { self, nixpkgs, monad-control-identity, deriving-trans, calligraphy }: {

     packages.x86_64-linux.default =
       with import nixpkgs { system = "x86_64-linux"; };
@@ -265,6 +272,7 @@
         buildInputs = with haskellPackages; [
           asciidoctor
           blaze-from-html
+          (callCabal2nix "calligraphy" calligraphy.outPath {})
           pkgs.findutils
           ghcid
           graphmod

Then I followed the tutorial

cabal clean
cabal build --ghc-options=-fwrite-ide-info
calligraphy -p out.png

This results in:

Invalid bounds:
    from    [8791026472627209831] (ValueDecl) SrcLoc "source/library/Homepage/Server/Route.hs" 19 1 SrcLoc "source/library/Homepage/Server/Route.hs" 19 1

This works:

calligraphy -e "Homepage.Server.Route" -e "Homepage.Server.Tab" -e "Homepage.Server.Route.Redirect" -e "Homepage.Server.Route.Donate" -e "Homepage.Server.Route.Blog.Atom" -e "Homepage.Server.Route.Files" -e "Homepage.Server.Route.Blog" -e "Homepage.Configuration" -e "Homepage.Configuration.Files" -e "Homepage.Configuration.Blog" -e "Homepage.Configuration.BaseUrl" -e "Homepage.Configuration.Contact" -p out.png

out

jonascarpay commented 2 years ago

Thanks for reporting! Unfortunately, there's an upstream issue with GHC 9.0.2 that prevents me from looking at the --ddump-hie-file dump and debugging this issue, and your project doesn't compile with 9.2.2 or 8.10.7, so I can't investigate further atm. I briefly tried to whip up a minimal example, but can't seem to reproduce it there...

L7R7 commented 2 years ago

I think I have a similar (the same?) issue with this project: https://github.com/L7R7/gitlab-ci-build-statuses The project writes the HIE file into .hie so I run calligraphy in this directory which gives me this error:

 calligraphy   
Invalid bounds:
    from    [8791026472627208724] (ValueDecl) SrcLoc "src/Metrics/Health.hs" 34 1 SrcLoc "src/Metrics/Health.hs" 34 1

The project compiles with GHC 8.10.7 and I installed calligraphy with this GHC version as well

If I go ahead end exclude this module and all others that lead to the same error:

calligraphy -e "Metrics.Health" -e "Config.Config" -e "Core.BuildStatuses" -e "Core.Runners" -p out.png

It produces an empty png file

jonascarpay commented 2 years ago

@L7R7 Thanks, I was able to build your project and isolate the culprit. With #3 your project works on my machine. When CI passes, I'll merge and make a new version.

jonascarpay commented 2 years ago

@jumper149 When you have a chance, please confirm if this also fixes the problem on your end!

L7R7 commented 2 years ago

WIth version 0.1.1 it runs fine and produces a png that's 3.5MB in size, but when I open it, it's still "empty" (I see a gray canvas). It's the same when outputting an SVG.

Since it doesn't fail anymore, that's probably something for a new issue?

jonascarpay commented 2 years ago

when I open it, it's still "empty"

I'm not sure what's going on. With calligraphy --hidden -p out.png I get this file, that's definitely not emtpy: out

L7R7 commented 2 years ago

Ah, I got fooled by my image viewer. It's not empty for me, but it was shown to me in a weird way. I'm sorry, my bad!

jumper149 commented 2 years ago

@jumper149 When you have a chance, please confirm if this also fixes the problem on your end!

Works like a charm :)