\begin{slide}{Datentransport über Kanal}

\begin{verbatim}
import Control.Concurrent ; import Control.Monad
main = do
  let top = 1000000000 ; let threads = 4
  ch <- newChan
  forM [ 0 .. threads - 1 ] $ \ t -> forkIO $ do
    let p = sum [ t, t+threads .. top -  1 ]
    print ( t, p )    
    writeChan ch p
  ps <- forM [ 0 .. threads - 1 ] $ \ t -> 
    readChan ch
  print $ sum ps
-- compile: ghc --make -O2 -threaded -rtsopts Sum.hs
-- run    : ./Sum +RTS -N4
\end{verbatim}

\end{slide}
