Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Pipes by Example
Search
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
堅牢なフロントエンドテスト基盤を構築するために行った取り組み
shogo4131
8
2.3k
エディターってAIで操作できるんだぜ
kis9a
0
710
dotfiles 式年遷宮 令和最新版
masawada
1
760
複数人でのCLI/Infrastructure as Codeの暮らしを良くする
shmokmt
5
2.3k
愛される翻訳の秘訣
kishikawakatsumi
1
320
AWS CDKの推しポイントN選
akihisaikeda
1
240
ZOZOにおけるAI活用の現在 ~モバイルアプリ開発でのAI活用状況と事例~
zozotech
PRO
8
5.5k
Cell-Based Architecture
larchanjo
0
110
UIデザインに役立つ 2025年の最新CSS / The Latest CSS for UI Design 2025
clockmaker
18
7.3k
20 years of Symfony, what's next?
fabpot
2
350
新卒エンジニアのプルリクエスト with AI駆動
fukunaga2025
0
200
なあ兄弟、 余白の意味を考えてから UI実装してくれ!
ktcryomm
11
11k
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.7k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.1k
Into the Great Unknown - MozCon
thekraken
40
2.2k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.6k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.3k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
970
GitHub's CSS Performance
jonrohan
1032
470k
Testing 201, or: Great Expectations
jmmastey
46
7.8k
Writing Fast Ruby
sferik
630
62k
Leading Effective Engineering Teams in the AI Era
addyosmani
8
1.3k
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