src.nth.io/

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/System/IO/Streams/Concurrent/Unagi/Bounded.hs23
-rw-r--r--unagi-streams.cabal3
2 files changed, 7 insertions, 19 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
diff --git a/unagi-streams.cabal b/unagi-streams.cabal
index 4529913..ed91f29 100644
--- a/unagi-streams.cabal
+++ b/unagi-streams.cabal
@@ -21,5 +21,6 @@ library
, unagi-chan >= 0.2 && < 0.3
, io-streams >= 1.2 && < 1.3
- hs-source-dirs: src/
+
+ hs-source-dirs: src
default-language: Haskell2010