packages feed

call-stack 0.2.0 → 0.4.0

raw patch · 6 files changed

Files

LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2016 Simon Hengel <sol@typeful.net>+Copyright (c) 2016-2021 Simon Hengel <sol@typeful.net>  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
call-stack.cabal view
@@ -1,13 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.0.+-- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack------ hash: ead73de1f27ca13dbc12434ae8a06a86ce7c6fc59801f6807140632fc1e44df8  name:           call-stack-version:        0.2.0+version:        0.4.0 synopsis:       Use GHC call-stacks in a backward compatible way category:       Data homepage:       https://github.com/sol/call-stack#readme@@ -26,7 +24,11 @@       src   ghc-options: -Wall   build-depends:-      base >=4.5.0.0 && <5+      base ==4.*+  if os(windows)+    cpp-options: -DWINDOWS+    build-depends:+        filepath   exposed-modules:       Data.CallStack   other-modules:@@ -41,8 +43,9 @@       test   ghc-options: -Wall   build-depends:-      base >=4.5.0.0 && <5+      base ==4.*     , call-stack+    , filepath     , nanospec   other-modules:       Data.CallStackSpec
src/Data/CallStack.hs view
@@ -1,11 +1,19 @@ {-# LANGUAGE CPP #-}-{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE ImplicitParams #-} +#if __GLASGOW_HASKELL__ >= 704+{-# LANGUAGE ConstraintKinds #-}+#define HasCallStack_ HasCallStack =>+#else+#define HasCallStack_+#endif+ module Data.CallStack (-  HasCallStack-, CallStack+#if __GLASGOW_HASKELL__ >= 704+  HasCallStack,+#endif+  CallStack , SrcLoc(..) , callStack , callSite@@ -14,6 +22,10 @@ import Data.Maybe import Data.SrcLoc +#ifdef WINDOWS+import System.FilePath+#endif+ #if MIN_VERSION_base(4,8,1) import qualified GHC.Stack as GHC #endif@@ -22,21 +34,37 @@ import           GHC.Stack (HasCallStack) #elif MIN_VERSION_base(4,8,1) type HasCallStack = (?callStack :: GHC.CallStack)-#else+#elif __GLASGOW_HASKELL__ >= 704 import GHC.Exts (Constraint) type HasCallStack = (() :: Constraint) #endif  type CallStack = [(String, SrcLoc)] -callStack :: HasCallStack => CallStack+callStack :: HasCallStack_ CallStack+callStack = workaroundForIssue19236 $ #if MIN_VERSION_base(4,9,0)-callStack = drop 1 $ GHC.getCallStack GHC.callStack+  drop 1 $ GHC.getCallStack GHC.callStack #elif MIN_VERSION_base(4,8,1)-callStack = drop 2 $ GHC.getCallStack ?callStack+  drop 2 $ GHC.getCallStack ?callStack #else-callStack = []+  [] #endif -callSite :: HasCallStack => Maybe (String, SrcLoc)+callSite :: HasCallStack_ Maybe (String, SrcLoc) callSite = listToMaybe (reverse callStack)++workaroundForIssue19236 :: CallStack -> CallStack -- https://gitlab.haskell.org/ghc/ghc/-/issues/19236+workaroundForIssue19236 =+#ifdef WINDOWS+  map (fmap fixSrcLoc)+  where+    fixSrcLoc :: SrcLoc -> SrcLoc+    fixSrcLoc loc = loc { srcLocFile = fixPath $ srcLocFile loc }++    fixPath :: FilePath -> FilePath+    fixPath =+      joinPath . splitDirectories+#else+  id+#endif
test/Data/CallStackSpec.hs view
@@ -15,10 +15,10 @@           , SrcLoc {               srcLocPackage = "main"             , srcLocModule = "Example"-            , srcLocFile = "test/Example.hs"-            , srcLocStartLine = 11+            , srcLocFile = "test" </> "Example.hs"+            , srcLocStartLine = 18             , srcLocStartCol = 7-            , srcLocEndLine = 11+            , srcLocEndLine = 18             , srcLocEndCol = 10             }           )@@ -26,10 +26,10 @@           , SrcLoc {               srcLocPackage = "main"             , srcLocModule = "Example"-            , srcLocFile = "test/Example.hs"-            , srcLocStartLine = 8+            , srcLocFile = "test" </> "Example.hs"+            , srcLocStartLine = 15             , srcLocStartCol = 8-            , srcLocEndLine = 8+            , srcLocEndLine = 15             , srcLocEndCol = 11             }           )
test/Example.hs view
@@ -1,5 +1,12 @@-{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE CPP, FlexibleContexts #-}++#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE ConstraintKinds #-}+#define HasCallStack_ HasCallStack =>+#else+#define HasCallStack_+#endif+ module Example where  import           Data.CallStack@@ -7,8 +14,8 @@ test :: CallStack test = foo -foo :: HasCallStack => CallStack+foo :: HasCallStack_ CallStack foo = bar -bar :: HasCallStack => CallStack+bar :: HasCallStack_ CallStack bar = callStack
test/Util.hs view
@@ -1,5 +1,7 @@ {-# LANGUAGE CPP #-}-module Util (SrcLoc(..), mapLocations) where+module Util (SrcLoc(..), mapLocations, (</>)) where++import           System.FilePath  #if MIN_VERSION_base(4,8,1) && !MIN_VERSION_base(4,9,0) import qualified GHC.SrcLoc as GHC