Fix some "warn-unused-do-bind" warnings where we want to ignore the value
[ghc-base.git] / Control / Concurrent / SampleVar.hs
index 4d88a19..a76346f 100644 (file)
 
 module Control.Concurrent.SampleVar
        (
-        -- * Sample Variables
+         -- * Sample Variables
          SampleVar,         -- :: type _ =
  
-        newEmptySampleVar, -- :: IO (SampleVar a)
+         newEmptySampleVar, -- :: IO (SampleVar a)
          newSampleVar,      -- :: a -> IO (SampleVar a)
-        emptySampleVar,    -- :: SampleVar a -> IO ()
-        readSampleVar,     -- :: SampleVar a -> IO a
-        writeSampleVar,    -- :: SampleVar a -> a -> IO ()
-        isEmptySampleVar,  -- :: SampleVar a -> IO Bool
+         emptySampleVar,    -- :: SampleVar a -> IO ()
+         readSampleVar,     -- :: SampleVar a -> IO a
+         writeSampleVar,    -- :: SampleVar a -> a -> IO ()
+         isEmptySampleVar,  -- :: SampleVar a -> IO Bool
 
        ) where
 
@@ -47,9 +47,9 @@ import Control.Concurrent.MVar
 --    (different from 'putMVar' on full 'MVar'.)
 
 type SampleVar a
- = MVar (Int,          -- 1  == full
-                       -- 0  == empty
-                       -- <0 no of readers blocked
+ = MVar (Int,           -- 1  == full
+                        -- 0  == empty
+                        -- <0 no of readers blocked
           MVar a)
 
 -- |Build a new, empty, 'SampleVar'
@@ -61,8 +61,7 @@ newEmptySampleVar = do
 -- |Build a 'SampleVar' with an initial value.
 newSampleVar :: a -> IO (SampleVar a)
 newSampleVar a = do
-   v <- newEmptyMVar
-   putMVar v a
+   v <- newMVar a
    newMVar (1,v)
 
 -- |If the SampleVar is full, leave it empty.  Otherwise, do nothing.
@@ -70,7 +69,7 @@ emptySampleVar :: SampleVar a -> IO ()
 emptySampleVar v = do
    (readers, var) <- takeMVar v
    if readers > 0 then do
-     takeMVar var
+     _ <- takeMVar var
      putMVar v (0,var)
     else
      putMVar v (readers,var)
@@ -112,6 +111,6 @@ writeSampleVar svar v = do
 --
 isEmptySampleVar :: SampleVar a -> IO Bool
 isEmptySampleVar svar = do
-   (readers,val) <- readMVar svar
+   (readers, _) <- readMVar svar
    return (readers == 0)