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
180
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Pipes by Example
Presented to YOW! Lambda Jam 2014.
Nick Partridge
May 09, 2014
Other Decks in Programming
See All in Programming
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
760
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
21
6.6k
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
Agentic UI
manfredsteyer
PRO
0
160
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
140
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
260
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
780
Webフレームワークの ベンチマークについて
yusukebe
0
170
RTSPクライアントを自作してみた話
simotin13
0
610
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.7k
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
180
ふつうのFeature Flag実践入門
irof
7
3.9k
Featured
See All Featured
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
250
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.2k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
250
The Cult of Friendly URLs
andyhume
79
6.9k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
54k
Claude Code のすすめ
schroneko
67
230k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
840
Test your architecture with Archunit
thirion
1
2.3k
Writing Fast Ruby
sferik
630
63k
Between Models and Reality
mayunak
4
340
New Earth Scene 8
popppiees
3
2.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