Removed opaque type for chan dupping.
authorLuke Hoersten <luke@hoersten.org>
Thu, 18 Dec 2014 10:56:53 -0600
changeset 3 400d49213290
parent 2 1760b7d150cf
child 4 1baf8e3b8ef2
Removed opaque type for chan dupping.
src/System/IO/Streams/Concurrent/Unagi/Bounded.hs
unagi-streams.cabal
--- a/src/System/IO/Streams/Concurrent/Unagi/Bounded.hs	Tue Dec 09 13:37:21 2014 -0600
+++ b/src/System/IO/Streams/Concurrent/Unagi/Bounded.hs	Thu Dec 18 10:56:53 2014 -0600
@@ -6,17 +6,14 @@
        , 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 @@
                                                         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 @@
 --
 -- 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
--- a/unagi-streams.cabal	Tue Dec 09 13:37:21 2014 -0600
+++ b/unagi-streams.cabal	Thu Dec 18 10:56:53 2014 -0600
@@ -21,5 +21,6 @@
               , unagi-chan >= 0.2 && < 0.3
               , io-streams >= 1.2 && < 1.3
 
-  hs-source-dirs:      src/
+
+  hs-source-dirs:      src
   default-language:    Haskell2010