src.nth.io/

summaryrefslogtreecommitdiff
path: root/src/System/IO
diff options
context:
space:
mode:
Diffstat (limited to 'src/System/IO')
-rw-r--r--src/System/IO/Streams/Concurrent/Unagi/Bounded.hs23
1 files changed, 5 insertions, 18 deletions
diff --git a/src/System/IO/Streams/Concurrent/Unagi/Bounded.hs b/src/System/IO/Streams/Concurrent/Unagi/Bounded.hs
index 83cb542..fe1e856 100644
--- a/src/System/IO/Streams/Concurrent/Unagi/Bounded.hs
+++ b/src/System/IO/Streams/Concurrent/Unagi/Bounded.hs
@@ -6,17 +6,14 @@ module System.IO.Streams.Concurrent.Unagi.Bounded
, chanToInput
, chanToOutput
, makeChanPipe
- , dupStream
- , DupHandle
) where
------------------------------------------------------------------------------
-import Control.Applicative (pure, (<$>), (<*>))
+import Control.Applicative ((<$>), (<*>))
import Control.Concurrent.Chan.Unagi.Bounded (InChan, OutChan,
- dupChan, newChan,
- readChan, writeChan)
-import Control.Monad ((>=>))
+ newChan, readChan,
+ writeChan)
import Prelude hiding (read)
import System.IO.Streams.Internal (InputStream,
OutputStream,
@@ -24,8 +21,6 @@ import System.IO.Streams.Internal (InputStream,
makeOutputStream, read)
-newtype DupHandle a = DupHandle { unDupHandle :: InChan (Maybe a) }
-
------------------------------------------------------------------------------
-- | Writes the contents of an input stream to a channel until the input stream
-- yields end-of-stream.
@@ -58,15 +53,7 @@ chanToOutput = makeOutputStream . writeChan
--
-- Since reading from the 'InputStream' and writing to the 'OutputStream' are
-- blocking calls, be sure to do so in different threads.
-makeChanPipe :: Int -> IO (InputStream a, OutputStream a, DupHandle a)
+makeChanPipe :: Int -> IO (InputStream a, OutputStream a)
makeChanPipe size = do
(inChan, outChan) <- newChan size
- (,,) <$> chanToInput outChan <*> chanToOutput inChan <*> pure (DupHandle inChan)
-
-
-------------------------------------------------------------------------------
--- | Use a 'DupHandle' to replicate everything written on the
--- associated 'OutputStream' to the 'InputStream'.
---
-dupStream :: DupHandle a -> IO (InputStream a)
-dupStream = dupChan . unDupHandle >=> chanToInput
+ (,) <$> chanToInput outChan <*> chanToOutput inChan