packages feed

debug-trace-var 0.1.0 → 0.2.0

raw patch · 4 files changed

+44/−8 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Debug.Trace.Var: traceMTH :: Name -> Q Exp

Files

ChangeLog.md view
@@ -1,3 +1,11 @@ # Changelog for debug-trace-var  ## Unreleased changes++## 0.2.0++* added: traceMTH, see [Add function to trace without QuasiQuote by igrep · Pull Request #2 · ncaq/debug-trace-var](https://github.com/ncaq/debug-trace-var/pull/2)++## 0.1.0++* added: first release
README.md view
@@ -28,10 +28,25 @@   [traceVarIO|a|] ~~~ +or++~~~hs+{-# LANGUAGE TemplateHaskell #-}+import           Debug.Trace.Var++main :: IO ()+main = let a = 1 :: Int+       in $(traceMTH 'a)+~~~++You may avoid name quotes that are confusing with character literals,+Or often it may be to avoid the QuasiQuotes to destroy the syntax highlight of the text editor.+ # Example  ~~~hs-{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE QuasiQuotes     #-}+{-# LANGUAGE TemplateHaskell #-}  import           Debug.Trace.Var @@ -71,6 +86,12 @@ e = do   let n = 344   [traceVarM|n|]++-- > f+-- n = 344+f :: IO ()+f = let n = 344+    in $(traceMTH 'n) ~~~  # Motivation
debug-trace-var.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 792b5b4b1b3e1126e975c29ffdfc6897c6a82e610ec0b8e38511c6ee20708c50+-- hash: d67e419c0b86880bb9f2ac794d527ed5cda823491865f20586475780f4f195b0  name:           debug-trace-var-version:        0.1.0+version:        0.2.0 synopsis:       You do not have to write variable names twice in Debug.Trace description:    Please see the README on GitHub at <https://github.com/ncaq/debug-trace-var#readme> category:       Debug
src/Debug/Trace/Var.hs view
@@ -1,6 +1,13 @@ {-# LANGUAGE QuasiQuotes     #-} {-# LANGUAGE TemplateHaskell #-}-module Debug.Trace.Var (traceVar, traceVarId, traceStackVar, traceVarIO, traceVarM) where+module Debug.Trace.Var+  ( traceMTH+  , traceVar+  , traceVarId+  , traceStackVar+  , traceVarIO+  , traceVarM+  ) where  import           Data.Maybe import           Debug.Trace@@ -8,6 +15,9 @@ import           Language.Haskell.TH.Quote import           Text.Show.Unicode +traceMTH :: Name -> Q Exp+traceMTH name = [|traceM $ $(stringE (nameBase name)) ++ $(stringE " = ") ++ ushow $(varE name)|]+ traceVar :: QuasiQuoter traceVar = traceVarBase [|trace|] @@ -34,7 +44,4 @@ traceFormat :: String -> Q Exp traceFormat str = do   valueName <- fromMaybe (error $ "variable " ++ str ++ " is not found") <$> lookupValueName str-  concatE <- [|concat|]-  ushowE <- [|ushow|]-  return $ AppE concatE $-    ListE [LitE (StringL str), LitE (StringL " = "), AppE ushowE (VarE valueName)]+  [| concat [$(stringE str), " = ", ushow $(varE valueName)] |]