Skip to content

Commit 4f32122

Browse files
committed
Removed opaque type for chan dupping.
1 parent 46a95a4 commit 4f32122

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

src/System/IO/Streams/Concurrent/Unagi/Bounded.hs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,21 @@ module System.IO.Streams.Concurrent.Unagi.Bounded
66
, chanToInput
77
, chanToOutput
88
, makeChanPipe
9-
, dupStream
10-
, DupHandle
119
) where
1210

1311

1412
------------------------------------------------------------------------------
15-
import Control.Applicative (pure, (<$>), (<*>))
13+
import Control.Applicative ((<$>), (<*>))
1614
import Control.Concurrent.Chan.Unagi.Bounded (InChan, OutChan,
17-
dupChan, newChan,
18-
readChan, writeChan)
19-
import Control.Monad ((>=>))
15+
newChan, readChan,
16+
writeChan)
2017
import Prelude hiding (read)
2118
import System.IO.Streams.Internal (InputStream,
2219
OutputStream,
2320
makeInputStream,
2421
makeOutputStream, read)
2522

2623

27-
newtype DupHandle a = DupHandle { unDupHandle :: InChan (Maybe a) }
28-
2924
------------------------------------------------------------------------------
3025
-- | Writes the contents of an input stream to a channel until the input stream
3126
-- yields end-of-stream.
@@ -58,15 +53,7 @@ chanToOutput = makeOutputStream . writeChan
5853
--
5954
-- Since reading from the 'InputStream' and writing to the 'OutputStream' are
6055
-- blocking calls, be sure to do so in different threads.
61-
makeChanPipe :: Int -> IO (InputStream a, OutputStream a, DupHandle a)
56+
makeChanPipe :: Int -> IO (InputStream a, OutputStream a)
6257
makeChanPipe size = do
6358
(inChan, outChan) <- newChan size
64-
(,,) <$> chanToInput outChan <*> chanToOutput inChan <*> pure (DupHandle inChan)
65-
66-
67-
------------------------------------------------------------------------------
68-
-- | Use a 'DupHandle' to replicate everything written on the
69-
-- associated 'OutputStream' to the 'InputStream'.
70-
--
71-
dupStream :: DupHandle a -> IO (InputStream a)
72-
dupStream = dupChan . unDupHandle >=> chanToInput
59+
(,) <$> chanToInput outChan <*> chanToOutput inChan

unagi-streams.cabal

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ library
2121
, unagi-chan >= 0.2 && < 0.3
2222
, io-streams >= 1.2 && < 1.3
2323

24-
hs-source-dirs: src/
24+
25+
hs-source-dirs: src
2526
default-language: Haskell2010

0 commit comments

Comments
 (0)