Skip to content

Commit

Permalink
Warn on usages of spy and spy' (#1691)
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.

This is how it is shown in my editor:

![image](https://github.com/user-attachments/assets/3e373c10-342f-40e3-ac4c-9f6375955626)

![image](https://github.com/user-attachments/assets/f7b500e9-3bf3-4bf1-b285-05c429a4986f)

---

* [x] CHANGELOG update not needed
* [x] Documentation update not needed
* [x] Haddocks updated
* [x] No new TODOs introduced
  • Loading branch information
locallycompact authored Oct 8, 2024
2 parents 57f81fc + 3d67013 commit 895a101
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hydra-node/src/Hydra/HeadLogic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ aggregate st = \case
{ coordinatedHeadState =
coordinatedHeadState
{ localUTxO = newLocalUTxO
, pendingDeposits = Map.delete (spy recoveredTxId) existingDeposits
, pendingDeposits = Map.delete recoveredTxId existingDeposits
}
}
where
Expand Down
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 895a101

Please sign in to comment.