module Control.Concurrent.Chan.WriteOnly 
( WriteOnlyChan
, ofChan
, writeChan
, writeList2Chan
) where

import qualified Control.Concurrent.Chan as Chan
import Control.Concurrent.Chan (Chan)

newtype WriteOnlyChan a = WriteOnlyChan (Chan a)

ofChan :: Chan a -> WriteOnlyChan a
ofChan = WriteOnlyChan

writeChan :: WriteOnlyChan a -> a -> IO ()
writeChan (WriteOnlyChan chan) =
  Chan.writeChan chan
  
dupChan :: WriteOnlyChan a -> IO (WriteOnlyChan a)
dupChan (WriteOnlyChan chan) = do
  dup <- Chan.dupChan chan
  return (ofChan dup)
  
writeList2Chan :: WriteOnlyChan a -> [a] -> IO ()
writeList2Chan (WriteOnlyChan chan) =
  Chan.writeList2Chan chan