Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
これって Effect でできたのでは? / TSKaigi Mashup Kansai #2
Search
Susisu
July 24, 2026
Programming
330
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
これって Effect でできたのでは? / TSKaigi Mashup Kansai #2
TSKaigi Mashup Kansai #2 TSKaigi 2026を振り返ろう!
の発表資料です
Susisu
July 24, 2026
More Decks by Susisu
See All by Susisu
tsc.rip を支える技術 / Kyoto.なんか #8
susisu
0
4.8k
Stage 3 Decorators でできること / できないこと / TSKaigi 2026
susisu
1
2.6k
Go で言うところのアレは TypeScript で言うとコレ / Kyoto.なんか #7
susisu
7
2.9k
君だけのオリジナル async / await を作ろう / TSKaigi 2025
susisu
20
16k
null or undefined
susisu
25
8.1k
Mackerel のフロントエンドフレームワーク移行 序章 / Hatena Engineer Seminar #13
susisu
0
2.3k
スクリーンショット撮影のために Puppeteer を操る / Kyoto.js 16
susisu
0
1k
BuckleScript 使ってみた
susisu
0
450
Atom パッケージ開発のすゝめ
susisu
1
2.4k
Other Decks in Programming
See All in Programming
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
200
AI-Powered Domain-Driven Design
ziobrando
0
240
Vue Fes Japan の “作る側”に関わってみて
naokihaba
1
180
🇪🇸 React Alicante 2026 (Workshop)
ythecombinator
PRO
0
100
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.7k
Railsバージョンを4倍にした話
optim
0
530
[JA] Domain Modeling with Vanilla Rails: 「操作」から再考するRailsの設計論
yasaichi
4
750
PyConTW 2026 - AI Coding 不只是工具升級, 區域醫院醫療資訊系統協作開發與資訊團隊轉型實踐
cclai999
0
150
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
230
AI時代のTerminal環境を UNIX哲学で設計・運用する
yasunori0418
1
200
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
130
JIS keyboard support in Omarchy
lef237
0
150
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
41
2.8k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Amusing Abliteration
ianozsvald
1
350
Marketing to machines
jonoalderson
1
5.9k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
830
How to Think Like a Performance Engineer
csswizardry
28
2.9k
Exploring anti-patterns in Rails
aemeredith
4
540
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
570
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
960
Writing Fast Ruby
sferik
630
63k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Transcript
これって Effectで できたの では? 2026-07-24 TSKaigi Mashup Kansai #2 susisu
こんにちは • /^(id:|@)susisu(2413)?$/ です • 株式会社はてな Webアプリケーションエンジニア / シニアエンジニア •
文字はデカければデカいほど 良いとされる
None
Stage 2.7 Decorators
印象に残った発表
None
None
賛否両論
我々はどうすべきか • (特にサーバーサイド TypeScript について) • Hono, Next.js などが全てをカバーしてくれるわけではない •
NestJS というかデコレータは先行き怪しい ff ff • E ect やっていき / E ect やめていき
わからない
調べてみよう
None
E ect • https://e ect.website • E ect-TS とも ff
ff ff • TypeScript の汎用ライブラリ/フレームワーク
解決したい課題 • 例外処理をいい感じにやりたい • DI をいい感じにやりたい • 並行処理をいい感じにやりたい • ...
https://susisu.hatenablog.com/entry/2022/11/04/211406
https://susisu.hatenablog.com/entry/2023/06/18/181507
https://speakerdeck.com/susisu/kyoto-dot-nanka-number-7
これって Effectで できたの では?
例外処理 • E ect では Effect<A, E> を使ってプログラムを表現する • c.f.
Promise<A>, Result<A, E> import { Effect } from "effect" ff const divide = ( a: number, b: number ): Effect.Effect<number, "DIVIDE_BY_ZERO"> => b === 0 ? Effect.fail("DIVIDE_BY_ZERO") : Effect.succeed(a / b)
例外処理 import { Console, Effect } from "effect" // main:
Effect.Effect<void, "DIVIDE_BY_ZERO"> const main = Effect.gen(function* () { const answer = yield* divide(42, 7) yield* Console.log(answer) }) Effect.runFork(main) // => 6
例外処理 import { Console, Effect, Either } from "effect" //
main: Effect.Effect<void, never> const main = Effect.gen(function*() { const answer = yield* divide(42, 7).pipe(Effect.either) if (Either.isLeft(answer)) return yield* Console.log(answer.right) }); Effect.runFork(main) // => 6
DI • E ect では Effect<A, E, R> を使ってプログラムを表現する ff
• R はプログラムの実行に必要な依存関係 (requirements)
DI import { Console, Context, Effect } from "effect" class
Random extends Context.Tag("MyRandomService")< Random, { readonly next: Effect.Effect<number> } >() {} // program: Effect.Effect<void, never, Random> const program = Effect.gen(function* () { const random = yield* Random const randomNumber = yield* random.next yield* Console.log(`random number: ${randomNumber}`) }) Effect.runFork(program) // ← 型エラー
DI // ... const runnable = Effect.provideService(program, Random, { next:
Effect.sync(() => Math.random()) }) Effect.runFork(runnable) // => 0.6792671590288922
並行処理 • Effect<A, E, R> は Fiber 上で実行される • 軽量スレッド,
Go でいうところの goroutine import { Effect, Fiber } from "effect" const main = Effect.gen(function* () { const fiber = yield* Effect.fork(child) // ... yield* Fiber.join(fiber) })
並行処理 • Fiber は中断可能 • Go では context.WithCancel を使ってやるようなやつ import
{ Effect, Fiber } from "effect" const main = Effect.gen(function* () { const fiber = yield* Effect.fork(child) yield* Effect.sleep("10 seconds") const exit = yield* Fiber.interrupt(fiber) });
並行処理 • 並行処理で使える Queue なども揃ってる • Go でいう channel など
import { Console, Effect, Fiber, Queue } from "effect" const main = Effect.gen(function* () { const queue = yield* Queue.bounded<number>(1) const fiber = yield* Effect.fork(Queue.take(queue).pipe(Effect.andThen(Console.log))) yield* Queue.offer(queue, 42) yield* Fiber.join(fiber) })
他にも色々 • リトライ • キャッシュ • リクエストのバッチ化 • c.f. p-retry,
lru-cache, dataloader
デメリット • pipe / ジェネレータを使った記法はややゴツく見えるかも • 外の世界のライブラリを使う場合は I/F を整える必要がある •
先述の通りあらかじめ用意されているものも多い • めちゃめちゃ機能が多い • ライブラリを探すのと同じように必要な機能だけ見れば良くはある
まとめ • E ect は汎用ライブラリ/フレームワーク • 例外処理, DI, 並行処理, その他諸々を扱うための道具が揃っている
ff • 採用するかは「場合による」けど、調べてみて選択の幅は広がった
余談 • fp-ts との関係と違い • Scala の ZIO との関係 •
Effect<A, E, R> を「エフェクト」と呼んでいいのか