Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Pipes by Example
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Nick Partridge
May 09, 2014
Programming
1
180
Pipes by Example
Presented to YOW! Lambda Jam 2014.
Nick Partridge
May 09, 2014
Tweet
Share
Other Decks in Programming
See All in Programming
CSC307 Lecture 06
javiergs
PRO
0
680
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
160
AI & Enginnering
codelynx
0
110
Data-Centric Kaggle
isax1015
2
760
OCaml 5でモダンな並列プログラミングを Enjoyしよう!
haochenx
0
140
Amazon Bedrockを活用したRAGの品質管理パイプライン構築
tosuri13
4
250
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
dchart: charts from deck markup
ajstarks
3
990
組織で育むオブザーバビリティ
ryota_hnk
0
170
「ブロックテーマでは再現できない」は本当か?
inc2734
0
730
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
170
[KNOTS 2026登壇資料]AIで拡張‧交差する プロダクト開発のプロセス および携わるメンバーの役割
hisatake
0
250
Featured
See All Featured
Joys of Absence: A Defence of Solitary Play
codingconduct
1
290
Agile that works and the tools we love
rasmusluckow
331
21k
How GitHub (no longer) Works
holman
316
140k
First, design no harm
axbom
PRO
2
1.1k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
180
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.5k
Darren the Foodie - Storyboard
khoart
PRO
2
2.3k
Evolving SEO for Evolving Search Engines
ryanjones
0
120
Marketing to machines
jonoalderson
1
4.6k
How STYLIGHT went responsive
nonsquared
100
6k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
53
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
90
Transcript
Pipes by Example Nick Partridge. nkpart on most things.
Why Pipes Because you’re writing a web server, of course.
Not just for streaming! produce :: m a consume ::
a -> m ()
Pipe Types Lead, PVC, etc.
Producers Consumers + Pipes Proxy a a’ b b’ m
c
Pipe a b m r a b m On exhaustion:
r Proxy () a () b m r
Producer b m r _ b m On exhaustion: r
Proxy X () () b m r
Consumer a m r a _ m On exhaustion: r
Proxy () a () X m r
The Primitives Because live coding always works.
Use the Monad Running producers sequentially is just >> When
pipes/consumers/producers/finish, they return a value Control.Monad and friends are very useful.
Elimination Finally some Category Theory.
Pipe a b m r a b m On exhaustion:
r
Effect m r m On exhaustion: r _ _ Proxy
X () () X m r
Substitution Producers: for or ~> eliminates yield Consumer side: >~
eliminates await
Elimination - Loop Bodies for generator body ! for x
yield == x for (yield x) f == f x
Companion Libraries Where the features are hiding.
Companion Libraries pipes-parse pipes-safe pipes-group
1. Pipes Parse type Parser a m r = forall
x. StateT (Producer a m x) m r Provides ‘push-back’. You can modify the underlying producer to return a value again.
2. Pipes Safe ReaderT (IORef (Finalizers m)) m r Resource
management, exception safety, through a monad transformer on m that allows registering Finalizers.
3. Pipes Group FreeT (Producer a m) m x Working
on sub-streams in constant memory. a ‘linked-list’ of sub-stream producers, each one returning the next sub-stream on exhaustion
return () :: Effect Talk ()
References Pipes haddocks - Pipes, Pipes.Prelude, Pipes.Tutorial Haskell for All
- Gabriel Gonzales’ blog Haskell Pipes Google Group “pipes-“ seach on hackage