debug-trace-var

You do not have to write variable names twice in Debug.Trace

https://github.com/ncaq/debug-trace-var#readme

Version on this page:0.1.0
LTS Haskell 23.26:0.2.0
Stackage Nightly 2025-07-06:0.2.0
Latest on Hackage:0.2.0

See all snapshots debug-trace-var appears in

MIT licensed by ncaq
Maintained by [email protected]
This version can be pinned in stack with:debug-trace-var-0.1.0@sha256:94d1ef622847e9dac3ff4b965f8267092bffbbe0255edf16ff930d7a26cd980e,1147

Module documentation for 0.1.0

Hackage Stackage LTS

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

Changes

Changelog for debug-trace-var

Unreleased changes