[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 14:50:43 UTC 2010


The following commit has been merged in the master branch:
commit 42bb3dd644da9b891af471fdb30ff18098d0f00e
Author: John Goerzen <jgoerzen at complete.org>
Date:   Thu Dec 16 02:05:23 2004 +0100

    Checkpointing work
    
    Keywords:
    
    
    (jgoerzen at complete.org--projects/missingh--head--0.7--patch-68)

diff --git a/ChangeLog b/ChangeLog
index e8f5286..bd24efb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,18 @@
 # arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.7
 #
 
+2004-12-15 19:05:23 GMT	John Goerzen <jgoerzen at complete.org>	patch-68
+
+    Summary:
+      Checkpointing work
+    Revision:
+      missingh--head--0.7--patch-68
+
+
+    modified files:
+     ChangeLog libsrc/MissingH/HVIO.hs
+
+
 2004-12-15 17:00:54 GMT	John Goerzen <jgoerzen at complete.org>	patch-67
 
     Summary:
diff --git a/libsrc/MissingH/HVIO.hs b/libsrc/MissingH/HVIO.hs
index b059f25..84caa80 100644
--- a/libsrc/MissingH/HVIO.hs
+++ b/libsrc/MissingH/HVIO.hs
@@ -44,13 +44,22 @@ where
 
 import System.IO
 import System.IO.Error
+import Control.Concurrent.MVar
+import Data.IORef
 
 {- | The HVIOGeneric class.
 
-Implementators must provide 'vClose' and 'vIsEOF'. -}
+Implementators must provide 'vClose', 'vIsEOF', and either
+'vIsOpen' or 'vIsClosed'. -}
 class (Show a) => HVIOGeneric a where
     -- | Close a file
     vClose :: a -> IO ()
+    -- | Test if a file is open
+    vIsOpen :: a -> IO Bool
+    -- | Test if a file is closed
+    vIsClosed :: a -> IO Bool
+    -- | Raise an error if the file is not open.
+    vTestOpen :: a -> IO ()
     -- | Whether or not we're at EOF
     vIsEOF :: a -> IO Bool
     -- | Detailed show output.
@@ -63,6 +72,7 @@ class (Show a) => HVIOGeneric a where
     -- May be Nothing.
     vGetFP :: a -> IO (Maybe FilePath)
     -- | Throw an isEOFError if we're at EOF; returns nothing otherwise.
+    -- vTestEOF will implicitly call vTestOpen.
     vTestEOF :: a -> IO ()
 
     vShow x = return (show x)
@@ -76,10 +86,17 @@ class (Show a) => HVIOGeneric a where
                   fp <- vGetFP h
                   ioError (vMkIOError h et "" fp)
 
-    vTestEOF h = do e <- vIsEOF h
+    vTestEOF h = do vTestOpen h
+                    e <- vIsEOF h
                     if e then vThrow h eofErrorType
                        else return ()
 
+    vIsOpen h = vIsClosed h >>= return . not
+    vIsClosed h = vIsOpen h >>= return . not
+    vTestOpen h = do e <- vIsClosed h
+                     if e then vThrow h illegalOperationErrorType
+                        else return ()
+
 {- | Readers.  Implementators must provide at least 'vGetChar'.
 -}
 class (HVIOGeneric a) => HVIOReader a where
@@ -121,13 +138,10 @@ class (HVIOGeneric a) => HVIOReader a where
 class (HVIOGeneric a) => HVIOWriter a where
     -- | Write one character
     vPutChar :: a -> Char -> IO ()
-
     -- | Write a string
     vPutStr :: a -> String -> IO ()
-
     -- | Write a string with newline character after it
     vPutStrLn :: a -> String -> IO ()
-
     -- | Write a string representation of the argument, plus a newline.
     vPrint :: Show b => a -> b -> IO ()
 
@@ -176,3 +190,20 @@ instance HVIOWriter Handle where
 instance HVIOSeeker Handle where
     vSeek = hSeek
     vTell = hTell
+
+----------------------------------------------------------------------
+-- VIO Support
+----------------------------------------------------------------------
+data VIOCloseSupport a = VIOCloseSupport {isOpen :: Bool,
+                                          vData :: a}
+
+----------------------------------------------------------------------
+-- Stream Readers/Writers
+----------------------------------------------------------------------
+
+{- | Simulate I\/O based on a string buffer.
+
+This is lazy!
+ -}
+data StreamReader = StreamReader (IORef (VIOCloseSupport String))
+

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list