-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Concurrent Chans as read/write pairs. Also provides generic Chan pair class. -- -- An implementation of concurrent channels identical to -- Control.Concurrent.Chan, except that the channel is represented as a -- pair, one of which allows only read operations, the other write -- operations. -- -- This makes code easier to reason about (the types strictly delegate -- read/write permission), suggests useful instances (e.g. Functor -- and Contravariant are easily defined) on the chan pairs, and -- simplifies the API. -- -- Furthermore this allows messages sent to channels with no readers to -- be trivially garbage-collected, without relying on inlining -- optimizations. -- -- We also provide a module that defines a class SplitChan which -- defines the basic methods any pair of Chan types should provide, -- allowing easy swapping of Chan implementations. -- -- To use standard Chans with these polymorphic functions, import as -- follows: -- --
--   import Control.Concurrent.Chan hiding (readChan,writeChan,writeList2Chan)
--   import Control.Concurrent.Chan.Class
--   
-- -- When used alongside standard Chans, the Split module can be imported -- qualified like: -- --
--   import qualified Control.Concurrent.Chan.Split as S
--   
-- -- Its interface is mostly backwards compatible with Chan. Note, we do -- not implement the deprecated unGetChan and isEmptyChan functions. -- -- This module is used internally by the simple-actors package. -- -- CHANGES: 0.3.0 -> 0.4.0 -- -- @package chan-split @version 0.4.0 module Control.Concurrent.Chan.Class -- | A class for chan types with a "write end" and a "read end". A minimal -- complete instance defines readChan and one of writeChan -- or writeList2Chan. class SplitChan i o | i -> o, o -> i where writeList2Chan = mapM_ . writeChan writeChan c = writeList2Chan c . return readChan :: SplitChan i o => o a -> IO a writeList2Chan :: SplitChan i o => i a -> [a] -> IO () writeChan :: SplitChan i o => i a -> a -> IO () -- | A class for SplitChan types that can be instantiated without -- programmer input. e.g. the standard haskell Chan is a -- member of this class, however a bounded chan type that took an -- Int to define the buffer size would not. class SplitChan i o => NewSplitChan i o newSplitChan :: NewSplitChan i o => IO (i a, o a) instance NewSplitChan MVar MVar instance SplitChan MVar MVar instance NewSplitChan Chan Chan instance SplitChan Chan Chan module Control.Concurrent.Chan.Split -- | The "write side" of a chan pair data InChan i -- | The "read side" of a chan pair data OutChan i -- | Return a lazy list representing the contents of the supplied OutChan, -- much like System.IO.hGetContents. getChanContents :: OutChan a -> IO [a] -- | Duplicate an OutChan: the duplicate channel contains any unread -- messages in the original (n.b. this differs from the behavior of -- dupChan in Chan), and data written to the corresponding InChan -- will appear in both, i.e. consuming a value from the copy will have no -- affect on the values in the original OutChan. -- -- (Note that a duplicated channel is not equal to its original. So: -- fmap (c /=) $ dupChan c returns True for all -- c.) dupChan :: OutChan a -> IO (OutChan a) instance Typeable1 InChan instance Typeable1 OutChan instance Eq (InChan i) instance Eq (OutChan i) instance SplitChan InChan OutChan instance NewSplitChan InChan OutChan