From 4696b60ec76b17895395ffe0c74ba3323de8aa09 Mon Sep 17 00:00:00 2001 From: Gil Mizrahi Date: Tue, 11 Apr 2023 12:05:14 +0300 Subject: [PATCH] chore(debugging): convert trace ghc warnings to hlint warnings PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8700 GitOrigin-RevId: 29b1ee9172bb10823420de9555c3e22f9846facd --- .hlint.yaml | 13 +++++++++++++ server/lib/hasura-prelude/src/Hasura/Prelude.hs | 12 ++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.hlint.yaml b/.hlint.yaml index 8e659d17949..9d0077fceef 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -71,6 +71,19 @@ within: [] message: "undefined isn't allowed" + ## Trace debugging + - name: "ltrace" + within: [] + message: "ltrace left in code" + - name: "ltraceM" + within: [] + message: "ltraceM left in code" + - name: "traceToFile" + within: [] + message: "traceToFile left in code" + - name: "traceToFileM" + within: [] + message: "traceToFileM left in code" ################################################################################ # Ignore some builtin hints diff --git a/server/lib/hasura-prelude/src/Hasura/Prelude.hs b/server/lib/hasura-prelude/src/Hasura/Prelude.hs index be32d889e99..10eff7250ff 100644 --- a/server/lib/hasura-prelude/src/Hasura/Prelude.hs +++ b/server/lib/hasura-prelude/src/Hasura/Prelude.hs @@ -299,12 +299,14 @@ tshow = T.pack . show -- | Labeled, prettified 'traceShowId'. ltrace :: Show a => String -> a -> a ltrace lbl x = Debug.trace (lbl <> ": " <> TL.unpack (PS.pShow x)) x -{-# WARNING ltrace "ltrace left in code" #-} + +{- HLINT ignore ltrace -} -- | Labeled, prettified 'traceShowM'. ltraceM :: Applicative m => Show a => String -> a -> m () ltraceM lbl x = Debug.traceM (lbl <> ": " <> TL.unpack (PS.pShow x)) -{-# WARNING ltraceM "ltraceM left in code" #-} + +{- HLINT ignore ltraceM -} -- | Trace a prettified value to a file. traceToFile :: Show a => FilePath -> a -> a @@ -312,7 +314,8 @@ traceToFile filepath x = Debug.trace ("tracing to " <> filepath) (unsafePerformIO (TLIO.writeFile filepath (PS.pShowNoColor x) $> x)) -{-# WARNING traceToFile "traceToFile left in code" #-} + +{- HLINT ignore traceToFile -} -- | Trace a prettified value to a file in an Applicative context. traceToFileM :: Applicative m => Show a => FilePath -> a -> m () @@ -323,7 +326,8 @@ traceToFileM filepath x = filepath, show $ unsafePerformIO $ TLIO.writeFile filepath $ PS.pShowNoColor x ] -{-# WARNING traceToFileM "traceToFileM left in code" #-} + +{- HLINT ignore traceToFileM -} -------------------------------------------------------------------------------- -- Map-related utilities