simple-pipe: simple pipeline library like conduit
examples/upperFile.hs
read file (sample.txt)
take 3 lines
to upper all lines
write to stdout
extensions
PackageImports
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 ()
Downloads
- simple-pipe-0.0.0.18.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
Versions [RSS] | 0.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, 0.0.0.29 |
---|---|
Dependencies | base (>=4 && <5), bytestring (>=0.10 && <0.11), lifted-base (>=0.2 && <0.3), monad-control (>=0.3 && <0.4), monads-tf (>=0.1 && <0.2) [details] |
License | BSD-3-Clause |
Author | Yoshikuni Jujo <PAF01143@nifty.ne.jp> |
Maintainer | Yoshikuni Jujo <PAF01143@nifty.ne.jp> |
Category | Data |
Home page | https://github.com/YoshikuniJujo/simple-pipe/wiki |
Source repo | head: 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.18) |
Uploaded | by YoshikuniJujo at 2014-08-20T04:34:04Z |
Distributions | |
Reverse Dependencies | 6 direct, 0 indirect [details] |
Downloads | 21064 total (69 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs available [build log] Successful builds reported [all 1 reports] |