From 8160d55ca73a164aed9540d82ac977c1b7bcd092 Mon Sep 17 00:00:00 2001
From: sof <unknown>
Date: Mon, 24 Nov 1997 20:40:59 +0000
Subject: [PATCH] [project @ 1997-11-24 20:40:59 by sof] Added Read BufferMode
 instance

---
 ghc/lib/required/IO.lhs | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/ghc/lib/required/IO.lhs b/ghc/lib/required/IO.lhs
index 4e058d3761b2..62345929352a 100644
--- a/ghc/lib/required/IO.lhs
+++ b/ghc/lib/required/IO.lhs
@@ -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}
 
 %*********************************************************
-- 
GitLab