You can also use the dump package that was written to handle this particular use case:
{-
What prints: (foo (bar 1) (bar 2)) = 5
It also processes more than one expression, separated by commas:
putStrLn [d| foo (bar 1) (bar 2), map bar [1, 2] |]
What prints: (foo (bar 1) (bar 2)) = 5 (map bar [1, 2]) = [2,3]
Bonus: If you have nix-shell installed (part of the nix package manager ), you can even quickly test it with this "one-liner":
$ nix-shell -p "nix-shell -p "haskellPackages.ghcWithPackages (p: [p.dump])" --run "echo '{-# language QuasiQuotes #-}; import Debug.Dump; foo = (+); bar = (+1); main = putStrLn [d| foo (bar 1) (bar 2), map bar [1, 2] |]' | runhaskell"
Wizek source share