dump: Dumps the names and values of expressions to ease debugging.

[ development, library, mit, quasiquotes ] [ Propose Tags ]

Can be used with Debug.Trace, Test.QuickCheck, or just plain old System.IO's "putStrLn".

See README.md and FEATURES.md for further details.


[Skip to Readme]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0, 0.1.1, 0.1.2, 0.2.0, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.2.5, 0.2.6, 0.2.7, 0.2.8
Change log CHANGES.md
Dependencies base (>=4 && <5), haskell-src-meta, interpolatedstring-perl6 (>=1.0 && <1.1), template-haskell, text [details]
License MIT
Author Milán Nagy
Maintainer dumplibhs.psssst@dfgh.net
Category Development, QuasiQuotes
Home page https://github.com/Wizek/dump
Source repo head: git clone git://github.com/Wizek/dump.git
Uploaded by Wizek at 2015-07-24T18:19:59Z
Distributions NixOS:0.2.8
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 7356 total (33 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for dump-0.2.8

[back to package description]

Example usage:

{-# LANGUAGE QuasiQuotes #-}

import Debug.Dump

main = print [d|a, a+1, map (+a) [1..3]|]
  where a = 2

which prints:

(a) = 2   (a+1) = 3       (map (+a) [1..3]) = [3,4,5]

by turnint this String

"a, a+1, map (+a) [1..3]"

into this expression

( "(a) = " ++ show (a)            ++ "\t  " ++
  "(a+1) = " ++ show (a + 1)      ++ "\t  " ++
  "(map (+a) [1..3]) = " ++ show (map (+ a) [1 .. 3])
)

QuickCheck

If you have any intermediate computation within a QuickCheck property, it can be useful to print a counterexample simply in case of failure

{-# LANGUAGE QuasiQuotes #-}

import Debug.Dump
import Test.QuickCheck

($>) = flip ($); infixl 0 $>

prop :: Float -> Property
prop n = n == 1 / (1 / n)
  $> counterexample [d|n, 1/n, 1/(1/n)|]

main = quickCheck prop

Which, when executed, will print something like this:

*** Failed! Falsifiable (after 15 tests and 133 shrinks):
1.7051912e-38
(n) = 1.7051912e-38   (1/n) = 5.864445e37   (1/(1/n)) = 1.7051913e-38

Isn't it nice to see the intermediate computations as well?

See also: list of features

Concieved at this StackOverflow question.