The dump package

[ Tags: 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]

Properties

Versions 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.*), haskell-src-meta, interpolatedstring-perl6 (==1.0.*), 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 repository head: git clone git://github.com/Wizek/dump.git
Uploaded Fri Jul 24 18:19:59 UTC 2015 by Wizek
Distributions NixOS:0.2.8
Downloads 1560 total (243 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


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.