file-location 0.4.0 → 0.4.1
raw patch · 3 files changed
+39/−2 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ FileLocation: fromJst :: Q Exp
+ FileLocation: fromRht :: Q Exp
Files
- Control/Exception/FileLocation.hs +19/−0
- FileLocation.hs +19/−1
- file-location.cabal +1/−1
Control/Exception/FileLocation.hs view
@@ -23,3 +23,22 @@ loc <- qLocation let locStr = locationToString loc [|(\mkEx -> throwIO (mkEx (locStr ++ " " ++ errMsg)))|]++{- usually want to make a located vesion of a function rather than use this.+ - perhaps it could be used to quickly make a located version+-- {-# LANGUAGE DeriveDataTypeable, ExistentialQuantification #-}+-- import Data.Typeable (Typeable)+data ReThrownException = forall e. (Exception e, Show e) => ReThrownException String e+ deriving (Typeable)++instance Show ReThrownException where+ show (ReThrownException s e) = "ReThrownException: " ++ s ++ "\n" ++ show e++instance Exception ReThrownException++reThrow :: Q Exp+reThrow = do+ loc <- qLocation+ let locStr = locationToString loc+ [|\risky -> E.catch risky (\e -> throwIO (ReThrownException locStr e))|]+ -}
FileLocation.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE TemplateHaskell #-} -- | see Debug.FileLocation module for more definitions module FileLocation- ( err, undef+ ( err, undef, fromJst, fromRht , debug, debugM, debugMsg, dbg, dbgMsg, trc, ltrace, ltraceM, strace , locationToString , thrwIO, thrwsIO@@ -39,3 +39,21 @@ loc <- qLocation let prefix = (locationToString loc) ++ " " [|trace (prefix ++ "undefined") undefined|]++-- | like fromJust, but also shows the file location+fromJst :: Q Exp+fromJst = do+ loc <- qLocation+ let msg = (locationToString loc) ++ " fromJst: Nothing"+ [|\m -> case m of+ Just v -> v+ Nothing -> error msg|]++-- | like fromRight, but also show the file location+fromRht :: Q Exp+fromRht = do+ loc <- qLocation+ let msg = (locationToString loc) ++ " fromRht: Left: "+ [|\m -> case m of+ Right v -> v+ Left e -> error (msg ++ show e)|]
file-location.cabal view
@@ -1,5 +1,5 @@ Name: file-location-Version: 0.4.0+Version: 0.4.1 Synopsis: common functions that show file location information Homepage: https://github.com/gregwebs/FileLocation.hs License: BSD3