git.iko.soy/typeable/haskell-stack-trace-plugin
on master help sign in
3 files changed+15−7
since splitsnapshots
unifiedsplit
Readme.md+4−2 haskell-stack-trace-plugin.cabal+2−2 src/StackTrace/Plugin.hs+9−3
Readme.md+4−2
@@ -5,8 +5,10 @@
55
66This plugin allow implicitly add `HasCallStack` class to every top-level function for all module. Hence, we can to get completely continuous call stack.
77
8−1. (implicitly) Import [GHC.Stack](https://hackage.haskell.org/package/base-4.12.0.0/docs/GHC-Stack.html) for all modules.
9−2. Add [HasCallStack](https://hackage.haskell.org/package/base-4.12.0.0/docs/GHC-Stack.html#t:HasCallStack) constraint for all top-level functions.
8+1. (implicitly) Import [GHC.Stack](https://hackage.haskell.org/package/base/docs/GHC-Stack.html) for all modules.
9+2. Add [HasCallStack](https://hackage.haskell.org/package/base/docs/GHC-Stack.html#t:HasCallStack) constraint for all top-level functions.
10+3. Other supported syntaxes
11+ - [x] `where` clause
1012
1113Requirement: (8.6 <= on GHC)
1214
haskell-stack-trace-plugin.cabal+2−2
@@ -32,13 +32,13 @@ flag dev
3232 default: False
3333
3434common common-opts
35− build-depends: base >=4.12 && <4.16
35+ build-depends: base >=4.12 && <4.18
3636 default-language: Haskell2010
3737
3838library
3939 import: common-opts
4040 hs-source-dirs: src
41− build-depends: ghc ^>=8.6 || ^>=8.8 || ^>=8.10 || ^>=9.0
41+ build-depends: ghc ^>=8.6 || ^>=8.8 || ^>=8.10 || ^>=9.0 || ^>=9.2 || ^>=9.4
4242 exposed-modules: StackTrace.Plugin
4343
4444 if flag(dev)
src/StackTrace/Plugin.hs+9−3
@@ -5,6 +5,7 @@ module StackTrace.Plugin (plugin) where
55
66import Control.Arrow (first)
77import Data.Monoid (Any(Any, getAny))
8+import GHC.Types.SrcLoc
89#if __GLASGOW_HASKELL__ >= 900
910import GHC.Plugins
1011#else
@@ -49,9 +50,14 @@ importDeclQualified = QualifiedPre
4950
5051ghcStackImport :: Located (ImportDecl (GhcPass p))
5152ghcStackImport =
52− noLoc $
53+ L srcSpan $
5354 (simpleImportDecl $ mkModuleName "GHC.Stack")
54− {ideclQualified = importDeclQualified, ideclAs = Just $ noLoc ghcStackModuleName}
55+ { ideclQualified = importDeclQualified, ideclAs = Just $ noLoc ghcStackModuleName }
56+ where
57+ -- This is for GHC-9 related problems. @noLoc@ causes GHC to throw warnings
58+ -- about unused imports. Even if the import is used
59+ -- See: https://github.com/waddlaw/haskell-stack-trace-plugin/issues/16
60+ srcSpan = RealSrcSpan (realSrcLocSpan $ mkRealSrcLoc "haskell-stack-trace-plugin:very-unique-file-name-to-avoid-collision" 1 1) Nothing
5561
5662#if __GLASGOW_HASKELL__ >= 900
5763updateHsModule :: HsModule -> HsModule
@@ -170,7 +176,7 @@ updateHsType ty@HsAppTy {} =
170176 flagASTModified $ HsQualTy xQualTy (noLoc $ appendHSC []) (noLoc ty)
171177updateHsType ty@HsFunTy {} =
172178 flagASTModified $ HsQualTy xQualTy (noLoc $ appendHSC []) (noLoc ty)
173−updateHsType ty@HsListTy {} =
179+updateHsType ty@HsListTy {} =
174180 flagASTModified $ HsQualTy xQualTy (noLoc $ appendHSC []) (noLoc ty)
175181updateHsType ty@HsTupleTy {} =
176182 flagASTModified $ HsQualTy xQualTy (noLoc $ appendHSC []) (noLoc ty)