@hackage debug-print0.2.0.1
A structured alternative to Show
Installation
Dependencies (9)
- aeson >=2.1.2.1
- base >=4.17.2.1 && <5
- containers >=0.6.7
- debug-print
- text >=2.0.2 Show all…
Dependents (1)
@hackage/iri-orphans
debug-print
Offers ToDebugPrintValue, a structured alternative to Show
for printing values for testing and debugging purposes.
import DebugPrint
import DebugPrint.Aeson
import Data.Aeson qualified as Aeson
data Report = Report
{ milliseconds :: Int
, errors :: [Text]
, fileName :: Maybe Text
}
deriving stock Generic
deriving anyclass (ToDebugPrintRecord, ToDebugPrintValue)
report :: Report
report = Report{ milliseconds = 5_824
, errors = ["Warning! Problems."]
, fileName = Nothing }
main :: IO ()
main = hspec $ do
it "" $ do
Aeson.encode (debugPrintValueToAeson report) `shouldBe`
"{\"errors\":[\"Warning! Problems.\"],\"milliseconds\":5824}"