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
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
登壇は dynamic! な営みである / speech is dynamic
da1chi
0
310
そのpreloadは必要?見過ごされたpreloadが技術的負債として爆発した日
mugitti9
2
3.3k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
330
Le côté obscur des IA génératives
pascallemerrer
0
140
CSC509 Lecture 04
javiergs
PRO
0
300
Flutterで分数(Fraction)を表示する方法
koukimiura
0
130
CI_CD「健康診断」のススメ。現場でのボトルネック特定から、健康診断を通じた組織的な改善手法
teamlab
PRO
0
210
チームの境界をブチ抜いていけ
tokai235
0
170
dynamic!
moro
10
7.6k
kiroとCodexで最高のSpec駆動開発を!!数時間で web3ネイティブなミニゲームを作ってみたよ!
mashharuki
0
170
なぜあの開発者はDevRelに伴走し続けるのか / Why Does That Developer Keep Running Alongside DevRel?
nrslib
3
400
明日から始めるリファクタリング
ryounasso
0
140
Featured
See All Featured
Unsuck your backbone
ammeep
671
58k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
46
7.7k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
Practical Orchestrator
shlominoach
190
11k
Side Projects
sachag
455
43k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
Thoughts on Productivity
jonyablonski
70
4.9k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
9
590
Six Lessons from altMBA
skipperchong
28
4k
Building a Scalable Design System with Sketch
lauravandoore
463
33k
How to Ace a Technical Interview
jacobian
280
24k
Designing for Performance
lara
610
69k
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