[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36

John Goerzen jgoerzen at complete.org
Fri Apr 23 15:11:41 UTC 2010


The following commit has been merged in the master branch:
commit 149e989a57de9b4e8b463173c600c1166611e377
Author: John Goerzen <jgoerzen at complete.org>
Date:   Tue Oct 10 21:36:04 2006 +0100

    Updated class

diff --git a/MissingH/ProgressTracker.hs b/MissingH/ProgressTracker.hs
index be519e5..5ef2ac6 100644
--- a/MissingH/ProgressTracker.hs
+++ b/MissingH/ProgressTracker.hs
@@ -58,15 +58,25 @@ data ProgressRecord =
 
 newtype Progress = Progress (MVar ProgressRecord)
 
-class ProgressTypes a where
-    withStatus :: a -> (ProgressRecord -> IO b) -> IO b
-
-instance ProgressTypes ProgressRecord where
-    withStatus x func = func x
-
-instance ProgressTypes Progress where
-    withStatus (Progress x) func = withMVar x func
-
-now :: ProgressTypes a => ProgressTimeSource
-now x = withStatus x timeSource
-
+class ProgressTypes a b where
+    withStatus :: a -> (ProgressStatus -> b) -> b
+    withRecord :: a -> (ProgressRecord -> b) -> b
+
+instance ProgressTypes ProgressRecord b where
+    withStatus x func = func (status x)
+    withRecord x func = func x
+
+instance ProgressTypes Progress (IO b) where
+    withStatus (Progress x) func = withMVar x (\y -> func (status y))
+    withRecord (Progress x) func = withMVar x func
+
+now :: ProgressTypes a ProgressTimeSource => a -> ProgressTimeSource
+now x = withRecord x timeSource
+
+new :: IO Progress
+new = 
+    do r <- newMVar $ ProgressRecord {timeSource = return 0,
+                                      parents = [],
+                                      callbacks = [],
+                                      status = ProgressStatus 0 1 1 ""}
+       return (Progress r)
\ No newline at end of file

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list