File tree Expand file tree Collapse file tree 5 files changed +43
-1
lines changed Expand file tree Collapse file tree 5 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -13,3 +13,4 @@ install:
1313 - npm install
1414script :
1515 - npm run build
16+ - npm run example
Original file line number Diff line number Diff line change 77
88* @scott-christopher for porting ` ListT ` and writing the ` MonadError ` ,
99 ` MonadWriter ` , ` MonadPlus ` and ` Alternative ` instances for ` Proxy ` !
10+
11+ ## How-To
12+
13+ For an in-depth overview of pipes follow the tutorial that comes with the
14+ Haskell pipes library. The concepts apply one to one to purescript-pipes.
15+
16+ Also have a look at the examples that come with purescript-pipes. You can run
17+ them using ` npm run example ` .
Original file line number Diff line number Diff line change 2323 "purescript-tailrec" : " ^3.0.0" ,
2424 "purescript-mmorph" : " ^3.0.0" ,
2525 "purescript-prelude" : " ^3.0.0"
26+ },
27+ "devDependencies" : {
28+ "purescript-console" : " ^3.0.0" ,
29+ "purescript-random" : " ^3.0.0"
2630 }
2731}
Original file line number Diff line number Diff line change 1+ module Example where
2+
3+ import Prelude
4+ import Control.Monad.Eff (Eff )
5+ import Control.Monad.Eff.Class (liftEff )
6+ import Control.Monad.Eff.Console (CONSOLE , log )
7+ import Control.Monad.Eff.Random (randomInt , RANDOM )
8+
9+ import Pipes (yield , for )
10+ import Pipes.Core (runEffect , Producer_ )
11+
12+ pipedRandomInt
13+ :: ∀ eff
14+ . Int
15+ -> Int
16+ -> Producer_ String (Eff (random :: RANDOM | eff )) Int
17+ pipedRandomInt x y = do
18+ yield $ " Generating an Int between " <> show x <> " and " <> show y <> " ..."
19+ r <- liftEff $ randomInt x y
20+ yield $ " Generated " <> show r
21+ pure r
22+
23+ main :: Eff (console :: CONSOLE , random :: RANDOM ) Unit
24+ main =
25+ let go = pipedRandomInt 1 10
26+ in do
27+ r <- runEffect $ for go (liftEff <<< log <<< (" Log: " <> _))
28+ log $ " Result: " <> show r
Original file line number Diff line number Diff line change 22 "private" : true ,
33 "scripts" : {
44 "postinstall" : " bower install" ,
5- "build" : " pulp build && rimraf docs && pulp docs"
5+ "build" : " pulp build && rimraf docs && pulp docs" ,
6+ "example" : " pulp run -I examples -I src -I bower_components -m example"
67 },
78 "devDependencies" : {
89 "bower" : " ^1.7.9" ,
You can’t perform that action at this time.
0 commit comments