@hackage debug-print0.1.0.0
A structured alternative to Show
Installation
Dependencies (9)
- aeson >=2.2.3.0
- base >=4.19.2.0 && <5
- containers >=0.6.8
- debug-print
- text >=2.1.1 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]
}
deriving stock Generic
deriving anyclass (ToDebugPrintRecord, ToDebugPrintValue)
report :: Report
report = Report{ milliseconds = 5_824
, errors = ["Warning! Problems."] }
main :: IO ()
main = hspec $ do
it "" $ do
Aeson.encode (debugPrintValueToAeson report) `shouldBe`
"{\"errors\":[\"Warning! Problems.\"],\"milliseconds\":5824}"