dump 0.2.2 → 0.2.3
raw patch · 4 files changed
+70/−5 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Debug.Dump: dd :: QuasiQuoter
Files
- FEATURES.md +42/−0
- README.md +1/−1
- dump.cabal +9/−3
- src/Debug/Dump.hs +18/−1
+ FEATURES.md view
@@ -0,0 +1,42 @@+# Description++To attain a changelog of this library between two arbitrary versions+you can use `git diff`. For example: `git diff v0.1.0..v0.2.0 -- FEATURES.md`++# Features++* Use it with Debug.Trace: `trace [d|x, y, z|] x`+* Use it with Test.QuickCheck: `counterexample [d|x, y, z|]`+* Use it inside the IO monad: `putStrLn [d|x, y, z|]`++* print out a variable `let a = 1 in print [d|a|]` outputing: `(a) = 1`+* print out an expression `print [d|1 + 2|]` outputting: `(1 + 2) = 3`+* refer to variables in the expression `let a = [1..3] in print [d|map (+1) a|]`+ outputing: `(map (+1) a) = [2,3,4]`+* print out multiple expressions `[d|1+2, 3+4|]` -> "(1+2) = 3 (3+4) = 7"+* tries a bit to line up expressions in columns.++ ```haskell+ main = do+ f 22+ f 333+ where f a = putStrLn [d|a, a+2|]+ ```+ Outputs:++ (a) = 22 (a+2) = 24+ (a) = 333 (a+2) = 335++# Beta features++* Support for expressions that contain commas inside them:+ An example: `[d|1, [2, 3]|]` -> "(1) = 1 ([2, 3]) = [2,3]"++ If your expression is invalid Haskell, such as `[d| ([)] |]` the generated+ code will be invalid as well, but could be slightly transformed. If you get+ cryptic error messages because of this, please let us know by opening+ an issue on GitHub.++# Known issues++n/a
README.md view
@@ -14,4 +14,4 @@ Have alook at the [list of features!](FEATURES.md). -*Concieved at http://stackoverflow.com/q/31349556/499478*+*Concieved at [this StackOverflow question](http://stackoverflow.com/q/31349556/499478).*
dump.cabal view
@@ -2,16 +2,22 @@ -- see http://haskell.org/cabal/users-guide/ name: dump-version: 0.2.2+version: 0.2.3+ synopsis: Dumps the names and values of expressions to ease debugging.-description: Example: "let a=1 in [d|a, a+1|] == \"(a) = 1, (a+1) = 2\""++description: 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.+ license: MIT license-file: LICENSE author: Milán Nagy maintainer: dumplibhs.psssst@dfgh.net category: Development build-type: Simple-extra-source-files: README.md+extra-source-files: README.md, FEATURES.md cabal-version: >=1.10 homepage: https://github.com/Wizek/dump
src/Debug/Dump.hs view
@@ -1,7 +1,18 @@ {-# OPTIONS_GHC -fno-warn-missing-fields #-} -module Debug.Dump (d, dump) where+{-| +`d`, `dd`, and `dump` are aliases of the same `QuasiQuoter`. you can choose to+imort just one of them:++@+import Debug.Dump (dd)+@++-}++module Debug.Dump (d, dd, dump) where+ import Utils import Data.List import Debug.Trace@@ -10,10 +21,16 @@ import Language.Haskell.Meta.Parse import Text.InterpolatedString.Perl6 ++-- | This is the main `QuasiQuoter`. dump :: QuasiQuoter dump = QuasiQuoter {quoteExp = process} +-- | Shorthand for `dump`. d = dump++-- | Shorthand for `dump`.+dd = dump process :: String -> Q Exp process str = pairsOf str $> parse $> return