Add some more debugging functions
authorIustin Pop <iustin@google.com>
Mon, 30 Aug 2010 09:10:06 +0000 (11:10 +0200)
committerIustin Pop <iustin@google.com>
Thu, 2 Sep 2010 12:43:16 +0000 (14:43 +0200)
These are just variations of the standard debug, but are provided for
simpler code, since lazyness is something causing non-computation of
debug statements.

Ganeti/HTools/Utils.hs

index 0d585b6..f827108 100644 (file)
@@ -2,7 +2,7 @@
 
 {-
 
-Copyright (C) 2009 Google Inc.
+Copyright (C) 2009, 2010 Google Inc.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -24,6 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 module Ganeti.HTools.Utils
     (
       debug
+    , debugFn
+    , debugXy
     , sepSplit
     , varianceCoeff
     , commaJoin
@@ -56,6 +58,14 @@ import Ganeti.HTools.Types
 debug :: Show a => a -> a
 debug x = trace (show x) x
 
+-- | Displays a modified form of the second parameter before returning it
+debugFn :: Show b => (a -> b) -> a -> a
+debugFn fn x = debug (fn x) `seq` x
+
+-- | Show the first parameter before returning the second one
+debugXy :: Show a => a -> b -> b
+debugXy a b = debug a `seq` b
+
 -- * Miscelaneous
 
 -- | Comma-join a string list.