/usr/share/doc/libghc-stm-doc/html/Control-Concurrent-STM-TChan.html is in libghc-stm-doc 2.4.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Control.Concurrent.STM.TChan</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Control-Concurrent-STM-TChan.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Control-Concurrent-STM-TChan.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">stm-2.4.2: Software Transactional Memory</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>non-portable (requires STM)</td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Maintainer</th><td>libraries@haskell.org</td></tr><tr><th>Safe Haskell</th><td>Trustworthy</td></tr></table><p class="caption">Control.Concurrent.STM.TChan</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">TChans
</a><ul><li><a href="#g:2">Construction
</a></li><li><a href="#g:3">Reading and writing
</a></li></ul></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>TChan: Transactional channels
(GHC only)
</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">data</span> <a href="#t:TChan">TChan</a> a</li><li class="src short"><a href="#v:newTChan">newTChan</a> :: <a href="Control-Monad-STM.html#t:STM">STM</a> (<a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a)</li><li class="src short"><a href="#v:newTChanIO">newTChanIO</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/System-IO.html#t:IO">IO</a> (<a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a)</li><li class="src short"><a href="#v:newBroadcastTChan">newBroadcastTChan</a> :: <a href="Control-Monad-STM.html#t:STM">STM</a> (<a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a)</li><li class="src short"><a href="#v:newBroadcastTChanIO">newBroadcastTChanIO</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/System-IO.html#t:IO">IO</a> (<a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a)</li><li class="src short"><a href="#v:dupTChan">dupTChan</a> :: <a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a -> <a href="Control-Monad-STM.html#t:STM">STM</a> (<a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a)</li><li class="src short"><a href="#v:readTChan">readTChan</a> :: <a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a -> <a href="Control-Monad-STM.html#t:STM">STM</a> a</li><li class="src short"><a href="#v:tryReadTChan">tryReadTChan</a> :: <a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a -> <a href="Control-Monad-STM.html#t:STM">STM</a> (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Maybe.html#t:Maybe">Maybe</a> a)</li><li class="src short"><a href="#v:peekTChan">peekTChan</a> :: <a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a -> <a href="Control-Monad-STM.html#t:STM">STM</a> a</li><li class="src short"><a href="#v:tryPeekTChan">tryPeekTChan</a> :: <a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a -> <a href="Control-Monad-STM.html#t:STM">STM</a> (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Maybe.html#t:Maybe">Maybe</a> a)</li><li class="src short"><a href="#v:writeTChan">writeTChan</a> :: <a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a -> a -> <a href="Control-Monad-STM.html#t:STM">STM</a> ()</li><li class="src short"><a href="#v:unGetTChan">unGetTChan</a> :: <a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a -> a -> <a href="Control-Monad-STM.html#t:STM">STM</a> ()</li><li class="src short"><a href="#v:isEmptyTChan">isEmptyTChan</a> :: <a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a -> <a href="Control-Monad-STM.html#t:STM">STM</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:cloneTChan">cloneTChan</a> :: <a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a -> <a href="Control-Monad-STM.html#t:STM">STM</a> (<a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a)</li></ul></div><div id="interface"><h1 id="g:1">TChans
</h1><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:TChan" class="def">TChan</a> a <a href="src/Control-Concurrent-STM-TChan.html#TChan" class="link">Source</a></p><div class="doc"><p><code><a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a></code> is an abstract type representing an unbounded FIFO channel.
</p></div><div class="subs instances"><p id="control.i:TChan" class="caption collapser" onclick="toggleSection('i:TChan')">Instances</p><div id="section.i:TChan" class="show"><table><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Typeable-Internal.html#t:Typeable1">Typeable1</a> <a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Eq.html#t:Eq">Eq</a> (<a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a)</td><td class="doc empty"> </td></tr></table></div></div></div><h2 id="g:2">Construction
</h2><div class="top"><p class="src"><a name="v:newTChan" class="def">newTChan</a> :: <a href="Control-Monad-STM.html#t:STM">STM</a> (<a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a)<a href="src/Control-Concurrent-STM-TChan.html#newTChan" class="link">Source</a></p><div class="doc"><p>Build and return a new instance of <code><a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a></code>
</p></div></div><div class="top"><p class="src"><a name="v:newTChanIO" class="def">newTChanIO</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/System-IO.html#t:IO">IO</a> (<a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a)<a href="src/Control-Concurrent-STM-TChan.html#newTChanIO" class="link">Source</a></p><div class="doc"><p><code>IO</code> version of <code><a href="Control-Concurrent-STM-TChan.html#v:newTChan">newTChan</a></code>. This is useful for creating top-level
<code><a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a></code>s using <code><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/System-IO-Unsafe.html#t:unsafePerformIO">unsafePerformIO</a></code>, because using
<code><a href="Control-Monad-STM.html#v:atomically">atomically</a></code> inside <code><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/System-IO-Unsafe.html#t:unsafePerformIO">unsafePerformIO</a></code> isn't
possible.
</p></div></div><div class="top"><p class="src"><a name="v:newBroadcastTChan" class="def">newBroadcastTChan</a> :: <a href="Control-Monad-STM.html#t:STM">STM</a> (<a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a)<a href="src/Control-Concurrent-STM-TChan.html#newBroadcastTChan" class="link">Source</a></p><div class="doc"><p>Create a write-only <code><a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a></code>. More precisely, <code><a href="Control-Concurrent-STM-TChan.html#v:readTChan">readTChan</a></code> will <code><a href="Control-Monad-STM.html#v:retry">retry</a></code>
even after items have been written to the channel. The only way to read
a broadcast channel is to duplicate it with <code><a href="Control-Concurrent-STM-TChan.html#v:dupTChan">dupTChan</a></code>.
</p><p>Consider a server that broadcasts messages to clients:
</p><pre>serve :: TChan Message -> Client -> IO loop
serve broadcastChan client = do
myChan <- dupTChan broadcastChan
forever $ do
message <- readTChan myChan
send client message
</pre><p>The problem with using <code><a href="Control-Concurrent-STM-TChan.html#v:newTChan">newTChan</a></code> to create the broadcast channel is that if
it is only written to and never read, items will pile up in memory. By
using <code><a href="Control-Concurrent-STM-TChan.html#v:newBroadcastTChan">newBroadcastTChan</a></code> to create the broadcast channel, items can be
garbage collected after clients have seen them.
</p></div></div><div class="top"><p class="src"><a name="v:newBroadcastTChanIO" class="def">newBroadcastTChanIO</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/System-IO.html#t:IO">IO</a> (<a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a)<a href="src/Control-Concurrent-STM-TChan.html#newBroadcastTChanIO" class="link">Source</a></p><div class="doc"><p><code>IO</code> version of <code><a href="Control-Concurrent-STM-TChan.html#v:newBroadcastTChan">newBroadcastTChan</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:dupTChan" class="def">dupTChan</a> :: <a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a -> <a href="Control-Monad-STM.html#t:STM">STM</a> (<a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a)<a href="src/Control-Concurrent-STM-TChan.html#dupTChan" class="link">Source</a></p><div class="doc"><p>Duplicate a <code><a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a></code>: the duplicate channel begins empty, but data written to
either channel from then on will be available from both. Hence this creates
a kind of broadcast channel, where data written by anyone is seen by
everyone else.
</p></div></div><h2 id="g:3">Reading and writing
</h2><div class="top"><p class="src"><a name="v:readTChan" class="def">readTChan</a> :: <a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a -> <a href="Control-Monad-STM.html#t:STM">STM</a> a<a href="src/Control-Concurrent-STM-TChan.html#readTChan" class="link">Source</a></p><div class="doc"><p>Read the next value from the <code><a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:tryReadTChan" class="def">tryReadTChan</a> :: <a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a -> <a href="Control-Monad-STM.html#t:STM">STM</a> (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Maybe.html#t:Maybe">Maybe</a> a)<a href="src/Control-Concurrent-STM-TChan.html#tryReadTChan" class="link">Source</a></p><div class="doc"><p>A version of <code><a href="Control-Concurrent-STM-TChan.html#v:readTChan">readTChan</a></code> which does not retry. Instead it
returns <code>Nothing</code> if no value is available.
</p></div></div><div class="top"><p class="src"><a name="v:peekTChan" class="def">peekTChan</a> :: <a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a -> <a href="Control-Monad-STM.html#t:STM">STM</a> a<a href="src/Control-Concurrent-STM-TChan.html#peekTChan" class="link">Source</a></p><div class="doc"><p>Get the next value from the <code>TChan</code> without removing it,
retrying if the channel is empty.
</p></div></div><div class="top"><p class="src"><a name="v:tryPeekTChan" class="def">tryPeekTChan</a> :: <a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a -> <a href="Control-Monad-STM.html#t:STM">STM</a> (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Maybe.html#t:Maybe">Maybe</a> a)<a href="src/Control-Concurrent-STM-TChan.html#tryPeekTChan" class="link">Source</a></p><div class="doc"><p>A version of <code><a href="Control-Concurrent-STM-TChan.html#v:peekTChan">peekTChan</a></code> which does not retry. Instead it
returns <code>Nothing</code> if no value is available.
</p></div></div><div class="top"><p class="src"><a name="v:writeTChan" class="def">writeTChan</a> :: <a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a -> a -> <a href="Control-Monad-STM.html#t:STM">STM</a> ()<a href="src/Control-Concurrent-STM-TChan.html#writeTChan" class="link">Source</a></p><div class="doc"><p>Write a value to a <code><a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:unGetTChan" class="def">unGetTChan</a> :: <a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a -> a -> <a href="Control-Monad-STM.html#t:STM">STM</a> ()<a href="src/Control-Concurrent-STM-TChan.html#unGetTChan" class="link">Source</a></p><div class="doc"><p>Put a data item back onto a channel, where it will be the next item read.
</p></div></div><div class="top"><p class="src"><a name="v:isEmptyTChan" class="def">isEmptyTChan</a> :: <a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a -> <a href="Control-Monad-STM.html#t:STM">STM</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a><a href="src/Control-Concurrent-STM-TChan.html#isEmptyTChan" class="link">Source</a></p><div class="doc"><p>Returns <code><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#v:True">True</a></code> if the supplied <code><a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a></code> is empty.
</p></div></div><div class="top"><p class="src"><a name="v:cloneTChan" class="def">cloneTChan</a> :: <a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a -> <a href="Control-Monad-STM.html#t:STM">STM</a> (<a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a> a)<a href="src/Control-Concurrent-STM-TChan.html#cloneTChan" class="link">Source</a></p><div class="doc"><p>Clone a <code><a href="Control-Concurrent-STM-TChan.html#t:TChan">TChan</a></code>: similar to dupTChan, but the cloned channel starts with the
same content available as the original channel.
</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.13.2</p></div></body></html>
|