The simple-pipe package

[Tags: bsd3, library]

examples/upperFile.hs

extensions

 import Data.Pipe
 import Data.Char
 import System.IO
 import "monads-tf" Control.Monad.Trans

 main :: IO ()
 main = do
 	_ <- runPipe $ readFileP "sample.txt"
		=$= takeP 3
		=$= convert (map toUpper)
		=$= writeString
 	return ()

 readFileP :: FilePath -> Pipe () String IO ()
 readFileP fp = bracket (openFile fp ReadMode) hClose hRead

 hRead :: Handle -> Pipe () String IO ()
 hRead h = do
 	eof <- lift $ hIsEOF h
 	if eof then return () else do
 		l <- lift $ hGetLine h
 		yield l
 		hRead h

 writeString :: Pipe String () IO ()
 writeString = do
 	ms <- await
 	case ms of
 		Just s -> lift (putStrLn s) >> writeString
 		_ -> return ()

 takeP :: Monad m => Int -> Pipe a a m ()
 takeP 0 = return ()
 takeP n = do
	mx <- await
	case mx of
		Just x -> yield x >> takeP (n - 1)
		_ -> return ()

Properties

Versions0.0.0.0, 0.0.0.1, 0.0.0.2, 0.0.0.3, 0.0.0.4, 0.0.0.5, 0.0.0.6, 0.0.0.7, 0.0.0.8, 0.0.0.9, 0.0.0.10, 0.0.0.11, 0.0.0.12, 0.0.0.13, 0.0.0.14, 0.0.0.15, 0.0.0.16, 0.0.0.17, 0.0.0.18, 0.0.0.19, 0.0.0.20, 0.0.0.21, 0.0.0.22, 0.0.0.23, 0.0.0.24, 0.0.0.25, 0.0.0.26, 0.0.0.27, 0.0.0.28
Change logNone available
Dependenciesbase (==4.*), bytestring (==0.10.*), lifted-base (==0.2.*), monad-control (==0.3.*), monads-tf (==0.1.*), stm (==2.4.*), transformers-base (==0.4.*) [details]
LicenseBSD3
AuthorYoshikuni Jujo <PAF01143@nifty.ne.jp>
MaintainerYoshikuni Jujo <PAF01143@nifty.ne.jp>
StabilityExperimental
CategoryData
Home pagehttps://github.com/YoshikuniJujo/simple-pipe/wiki
Source repositoryhead: git clone git://github.com/YoshikuniJujo/simple-pipe.git
this: git clone git://github.com/YoshikuniJujo/simple-pipe.git(tag simple-pipe-0.0.0.28)
UploadedFri Aug 29 08:46:17 UTC 2014 by YoshikuniJujo
DistributionsNixOS:0.0.0.28
Downloads2914 total (187 in last 30 days)
Votes
0 []
StatusDocs available [build log]
Successful builds reported [all 1 reports]

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees