@hackage debug-trace-var0.1.0
You do not have to write variable names twice in Debug.Trace
Categories
License
MIT
Maintainer
ncaq@ncaq.net
Links
Versions
Installation
Dependencies (3)
- base >=4.7 && <5
- template-haskell
- unicode-show Show all…
Dependents (1)
@hackage/acme-everything
debug-trace-var
When writing print debug, we often write.
import Debug.Trace
main :: IO ()
main = do
let a = 1
traceIO $ "a = " ++ show a
This is troublesome to describe the name of the variable twice.
With debug-trace-var you write variables only once.
{-# LANGUAGE QuasiQuotes #-}
import Debug.Trace.Var
main :: IO ()
main = do
let a = 1
[traceVarIO|a|]
Example
{-# LANGUAGE QuasiQuotes #-}
import Debug.Trace.Var
-- > a
-- n = 1
-- s = "あ"
a :: IO ()
a = let n = 1
s = "あ"
in [traceVar|n|] ([traceVar|s|] return ())
-- > b
-- "n = 1
-- n = 1"
b :: String
b = let n = 1
in [traceVarId|n|]
-- > c
-- n = 344
c :: IO ()
c = let n = 344
in [traceStackVar|n|] (return ())
-- > d
-- n = 344
-- n = 344
d :: IO ()
d = do
let n = 344
[traceVarIO|n|]
[traceVarIO|n|]
-- > e
-- n = 344
e :: IO ()
e = do
let n = 344
[traceVarM|n|]
Motivation
I wanted to use Template Haskell.
One point advice
You can use ndmitchell/debug: Haskell library for debugging