Skip to content

Commit

Permalink
Warn on usages of spy and spy'
Browse files Browse the repository at this point in the history
These functions should not remain in production code and only be used
for debugging purposes only.
  • Loading branch information
ch1bo committed Oct 8, 2024
1 parent 57f81fc commit a389b1e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions hydra-prelude/src/Hydra/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,11 @@ withFile fp mode action =
Right x -> pure x

-- | Like 'traceShow', but with pretty printing of the value.
{-# WARNING spy "Use for debugging purposes only" #-}
spy :: Show a => a -> a
spy a = trace (toString $ pShow a) a

-- | Like 'spy' but prefixed with a label.
{-# WARNING spy' "Use for debugging purposes only" #-}
spy' :: Show a => String -> a -> a
spy' msg a = trace (msg <> ": " <> toString (pShow a)) a

0 comments on commit a389b1e

Please sign in to comment.