{"id":18571845,"url":"https://github.com/waddlaw/haskell-stack-trace-plugin","last_synced_at":"2025-04-10T07:30:48.594Z","repository":{"id":51073387,"uuid":"160778919","full_name":"waddlaw/haskell-stack-trace-plugin","owner":"waddlaw","description":null,"archived":false,"fork":false,"pushed_at":"2022-10-24T21:17:07.000Z","size":38,"stargazers_count":18,"open_issues_count":5,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-24T20:28:12.688Z","etag":null,"topics":["compiler-plugin","haskell","source-plugin"],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/waddlaw.png","metadata":{"files":{"readme":"Readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-07T06:06:43.000Z","updated_at":"2024-02-21T20:30:23.000Z","dependencies_parsed_at":"2022-09-21T09:23:23.668Z","dependency_job_id":null,"html_url":"https://github.com/waddlaw/haskell-stack-trace-plugin","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waddlaw%2Fhaskell-stack-trace-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waddlaw%2Fhaskell-stack-trace-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waddlaw%2Fhaskell-stack-trace-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waddlaw%2Fhaskell-stack-trace-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/waddlaw","download_url":"https://codeload.github.com/waddlaw/haskell-stack-trace-plugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223430338,"owners_count":17143624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler-plugin","haskell","source-plugin"],"created_at":"2024-11-06T23:03:57.539Z","updated_at":"2024-11-06T23:03:57.605Z","avatar_url":"https://github.com/waddlaw.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# haskell-stack-trace-plugin\n\n![](https://github.com/waddlaw/haskell-stack-trace-plugin/workflows/cabal/badge.svg)\n[![Hackage](https://img.shields.io/hackage/v/haskell-stack-trace-plugin.svg)](https://hackage.haskell.org/package/haskell-stack-trace-plugin)\n\nThis plugin allow implicitly add `HasCallStack` class to every top-level function for all module. Hence, we can  to get completely continuous call stack.\n\n1. (implicitly) Import [GHC.Stack](https://hackage.haskell.org/package/base/docs/GHC-Stack.html) for all modules.\n2. Add [HasCallStack](https://hackage.haskell.org/package/base/docs/GHC-Stack.html#t:HasCallStack) constraint for all top-level functions.\n3. Other supported syntaxes\n    - [x] `where` clause\n\nRequirement: (8.6 \u003c= on GHC)\n\n## Synopsis\n\n```haskell\nmodule Main where\n\nimport Data.Maybe (fromJust)\n\nmain :: IO ()\nmain = print f1\n\nf1 :: Int\nf1 = f2\n\nf2 :: Int\nf2 = f3\n\n-- HsQualTy\nf3 :: HasCallStack =\u003e Int\nf3 = f4 0\n\n-- HsQualTy\nf4 :: Show a =\u003e a -\u003e Int\nf4 n = f5 (show n) 0\n\n-- HsFunTy\nf5 :: String -\u003e Int -\u003e Int\nf5 _ _ = head f6\n\n-- HsListTy\nf6 :: [Int]\nf6 = [fst f7]\n\n-- HsTupleTy\nf7 :: (Int, Int)\nf7 = (fromJust f8, fromJust f8)\n\n-- HsAppTy\nf8 :: Maybe Int\nf8 = Just f9\n\nf9 :: Int\nf9 = f10\n  where\n    f10 :: Int\n    f10 = fError\n\n-- HsTyVar\nfError :: Int\nfError = error \"fError\"\n```\n\nThis example get error:\n\n```shell\n$ cabal build\nexample/Main.hs:15:7: error:\n    Not in scope: type constructor or class ‘HasCallStack’\n   |\n15 | f3 :: HasCallStack =\u003e Int\n   |       ^^^^^^^^^^^^\n```\n\nYes, add `import GHC.Stack` to above example.\n\nFix and rebuild!\n\n```shell\n$ cabal run example -v0\nexample: fError\nCallStack (from HasCallStack):\n  error, called at example/Main.hs:47:10 in main:Main\n```\n\nHmm, it is not useful. But, you will to be happy when enable this plugin.\n\n```cabal\n  ghc-options:\n    -fplugin=StackTrace.Plugin\n```\n\n```shell\n$ cabal run example -v0\nexample: fError\nCallStack (from HasCallStack):\n  error, called at example/Main.hs:47:10 in main:Main\n  fError, called at example/Main.hs:43:11 in main:Main\n  f10, called at example/Main.hs:40:6 in main:Main\n  f9, called at example/Main.hs:37:11 in main:Main\n  f8, called at example/Main.hs:33:16 in main:Main\n  f7, called at example/Main.hs:29:11 in main:Main\n  f6, called at example/Main.hs:25:15 in main:Main\n  f5, called at example/Main.hs:21:8 in main:Main\n  f4, called at example/Main.hs:17:6 in main:Main\n  f3, called at example/Main.hs:13:6 in main:Main\n  f2, called at example/Main.hs:10:6 in main:Main\n  f1, called at example/Main.hs:7:14 in main:Main\n  main, called at example/Main.hs:7:1 in main:Main\n```\n\nGreat!!!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaddlaw%2Fhaskell-stack-trace-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwaddlaw%2Fhaskell-stack-trace-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaddlaw%2Fhaskell-stack-trace-plugin/lists"}