packages feed

simple-pipe 0.0.0.21 → 0.0.0.22

raw patch · 2 files changed

+12/−5 lines, 2 files

Files

simple-pipe.cabal view
@@ -2,7 +2,7 @@ cabal-version:	>= 1.8  name:		simple-pipe-version:	0.0.0.21+version:	0.0.0.22 stability:	Experimental author:		Yoshikuni Jujo <PAF01143@nifty.ne.jp> maintainer:	Yoshikuni Jujo <PAF01143@nifty.ne.jp>@@ -80,7 +80,7 @@ source-repository	this     type:	git     location:	git://github.com/YoshikuniJujo/simple-pipe.git-    tag:	simple-pipe-0.0.0.21+    tag:	simple-pipe-0.0.0.22  library     hs-source-dirs:	src
src/Data/Pipe/TChan.hs view
@@ -1,13 +1,12 @@ {-# LANGUAGE FlexibleContexts, PackageImports #-} -module Data.Pipe.TChan (-	fromTChan, fromTChans, toTChan,-	) where+module Data.Pipe.TChan (fromTChan, toTChan, fromTChans, toTChans) where  import Control.Applicative import "monads-tf" Control.Monad.Trans import Control.Monad.Base import Control.Concurrent.STM+import Data.List import Data.Pipe  fromTChan :: (PipeClass p, MonadBase IO m,@@ -29,3 +28,11 @@ 	MonadTrans (p a x), Monad (p a x m)) => TChan a -> p a x m () toTChan c = await >>= maybe (return ()) 	((>> toTChan c) . lift . liftBase . atomically . writeTChan c)++toTChans :: (PipeClass p, MonadBase IO m,+	MonadTrans (p (a, b) x), Monad (p (a, b) x m)) =>+	[(a -> Bool, TChan b)] -> p (a, b) x m ()+toTChans cs = (await >>=) . maybe (return ()) $ \(t, x) -> (>> toTChans cs) $+	case find (($ t) . fst) cs of+		Just (_, c)-> lift . liftBase . atomically $ writeTChan c x+		_ -> return ()