-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Concurrent Chans as read/write pairs. Also provides generic Chan, Cofunctor classes. -- -- A wrapper around Control.Concurrent.Chan that splits a Chan into a -- pair, one of which allows only read operations, the other write -- operations. -- -- This makes code easier to reason about, allows us to define useful -- instances (Functor and Cofunctor) on the chan pairs. -- -- In addition this package provides a module that defines a pair of -- classes ReadableChan and WritableChan which defines the -- basic methods any Chan type should provide. -- -- 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
--   
-- -- Note, we do not implement the deprecated unGetChan and isEmptyChan -- functions. -- -- This module is used internally by the simple-actors package. -- -- CHANGES: 0.1.3 -> 0.2.0 - moved Data.Cofunctor to -- its own module cofunctor - redefine chan pair classes using -- fundeps to express the relationship between input and output halfs of -- a Chan - define NewSplitChan class for chan pairs that can be -- instantiated @package chan-split @version 0.2.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 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 o -- | 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 begins empty, but -- 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. dupChan :: OutChan a -> IO (OutChan a) instance Functor OutChan instance Cofunctor InChan instance SplitChan InChan OutChan instance NewSplitChan InChan OutChan