[project @ 1997-11-24 20:40:59 by sof]
authorsof <unknown>
Mon, 24 Nov 1997 20:40:59 +0000 (20:40 +0000)
committersof <unknown>
Mon, 24 Nov 1997 20:40:59 +0000 (20:40 +0000)
Added Read BufferMode instance

ghc/lib/required/IO.lhs

index 4e058d3..6234592 100644 (file)
@@ -40,6 +40,7 @@ import ArrBase                ( MutableByteArray(..), newCharArray )
 import IOHandle                -- much of the real stuff is in here
 import PackBase                ( unpackNBytesST )
 import PrelBase
+import PrelRead         ( readParen, Read(..), reads, lex )
 import PrelMaybe
 import PrelEither
 import GHC
@@ -129,6 +130,18 @@ instance Show Handle where {showsPrec p h = showString "<<Handle>>"}
 instance Eq HandlePosn where
     (HandlePosn h1 p1) == (HandlePosn h2 p2) = p1==p2 && h1==h2
 
+-- Type declared in IOBase, instance here because it
+-- depends on PrelRead.(Read Maybe) instance.
+instance Read BufferMode where
+    readsPrec p = 
+      readParen False
+       (\r ->  let lr = lex r
+               in
+               [(NoBuffering, rest)       | ("NoBuffering", rest) <- lr] ++
+               [(LineBuffering,rest)      | ("LineBuffering",rest) <- lr] ++
+               [(BlockBuffering mb,rest2) | ("BlockBuffering",rest1) <- lr,
+                                            (mb, rest2) <- reads rest1])
+
 \end{code}
 
 %*********************************************************