Skip to content

Instantly share code, notes, and snippets.

@tmhedberg
Created February 15, 2013 01:05
Show Gist options
  • Select an option

  • Save tmhedberg/4957861 to your computer and use it in GitHub Desktop.

Select an option

Save tmhedberg/4957861 to your computer and use it in GitHub Desktop.
Template Haskell macro for producing less repetitive debugging statements. Requires the `th-orphans` package.
{-# LANGUAGE TemplateHaskell #-}
module NiceDebug where
import Debug.Trace
import Language.Haskell.TH
import Language.Haskell.TH.Instances
debug :: Name -> Q Exp
debug name = [|trace $ nameBase name ++ ": " ++ show $(varE name)|]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment