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
ねことはじめる関数型 / functional programming with cats
Search
ぷに
February 29, 2020
Technology
1.3k
1
Share
ねことはじめる関数型 / functional programming with cats
VRC LT #7
ぷに
February 29, 2020
More Decks by ぷに
See All by ぷに
数値計算の呪いとあそぼぅ!!/ the curse of numerical calculus
punilfin
1
47
Other Decks in Technology
See All in Technology
3つのボトルネックを解消し、リリースエンジニアリングを再定義した話
nealle
0
430
シン・リスコフの置換原則 〜現代風に考えるSOLIDの原則〜
jinwatanabe
0
200
Code Interpreter で、AIに安全に コードを書かせる。
yokomachi
0
5k
AIがコードを書く時代の ジェネレーティブプログラミング
polidog
PRO
3
740
サイバーフィジカル社会とは何か / What Is a Cyber-Physical Society?
ks91
PRO
0
170
Azure Static Web Apps の自動ビルドがタイムアウトしやすくなった状況に対応した件/global-azure2026
thara0402
0
190
建設的な現実逃避のしかた / How to practice constructive escapism
pauli
4
330
Azure PortalなどにみるWebアクセシビリティ
tomokusaba
0
230
NgRx SignalStore: The Power of Extensibility
rainerhahnekamp
0
220
DevOpsDays Tokyo 2026 見えない開発現場を、見える投資に変える
rojoudotcom
3
190
OBI+APMでお手軽にアプリケーションのオブザーバビリティを手に入れよう
kenshimuto
0
290
ルールルルルル私的函館観光ガイド── 函館の街はイクラでも楽しめる!
nomuson
0
190
Featured
See All Featured
Utilizing Notion as your number one productivity tool
mfonobong
4
290
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Designing Powerful Visuals for Engaging Learning
tmiket
1
330
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
320
The agentic SEO stack - context over prompts
schlessera
0
740
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
199
73k
[SF Ruby Conf 2025] Rails X
palkan
2
940
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
310
Google's AI Overviews - The New Search
badams
0
960
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
680
Transcript
Ͷ͜ͱ͡ΊΔؔܕ ʹ (ehlfin_puni / punilfin) 2020/03/27
͜͡͠ΐ͏͔͍ ͳ·͑ɿʹ VRC ID : ehlfin_puni Twitter : punilfin 2020/02/10
ʹ VRC ʹ͖·ͨ͠ ͠ΐ͠Μ͠ΌͰ͢ɽͯ͘͞͠͠Ͷ ͖͢ɿ͢͏͕͘ ͖͚ͩ͢ͲͳʹΘ͔Βͳ͍Ͱ͢ɽͯ͘͞͠͠Ͷ ͖͢͡Όͳ͍ɿΖ͙ΒΈΜ͙ ͱ ͖͔͍͕͘͠Ύ͏ ͱ͘ʹ͖Β͍ɿ JavaScript
͍·͔Β Scala with Cats ͱ͍͏ຊͷΛ͠·͢ Cats Λμγʹͯؔ͠ܕͷߟ͑ํΛֶͿຊ Cats ʜ Scala
ͰΰϦΰϦؔܕ͢ΔͷΛิॿ͢ΔϥΠϒϥϦ Cats ͷ͍ํΛֶͿຊ
͜͜ʹ͋Γ·͢ Figure: https://underscore.io/books/scala-with-cats/
ಡΜͩܦҢ ͓͠͝ͱͰ Scala ͷϨϏϡʔΛ͠ͳ͍ͱ͍͚ͳ͍ Scala Βͳ͍ʂ ݍษڧ͚ͯͨ͠Ͳ Monad ͕ग़ͯ͘Δલʹ͖ͯΊͨ Monad
Βͳ͍ʂ ྆ํ·ͱΊͯษڧͰ͖ͳ͍͔ͳʁ
ຊͷষཱͯ Monoids and Semigroups Functors Monads Monad Transformers Semigroupal and
Applicative Foldable and Traverse Testing Asynchronous Code Map-Reduce Data Validation CRDTs ײ ාͦ͏
ಡΜͰΈͨײ ͋·Γා͘ͳ͍ Option, Future, List ͳͲɼScala ͰΑ͘͏֓೦ΛΑ͘ݟ͢ͱ͜Ζ͔Βελʔτ ͦΕΒͷڞ௨ੑ࣭ΛऔΓग़͢͜ͱͰ Monad ͳͲͷந֓೦ঃʑʹ
࠷ۙ͋ͬͨ͜ͱ Javascript ͷ࣭Λ͞Εͨ Γ͍ͨ͜ͱɿ ʮ2 ͭͷ Promise ͷ݁Ռ͕ग़ଗ͔ͬͯΒɺ2 ͭͷ݁ՌΛՃͯ͠ฦ͢ʯ ฉ͍ͨॠؒʹʮݴޠͷ
built-in ͚ؔͩͰͰ͖ͦ͏ͩʯͱࢥͬͨ ௐͨΒ Promise.all() ͕ώοτͨ͠
ਪաఔ ܕΫϥε F ʹରͯ͠ F[A] ͱ F[B] ͔Β F[A,B] ܕΛ࡞Γ͍ͨ
F ͕ Cartesian ͳΒ product ͰͰ͖Δ ͳͷͰ Promise ͕ Cartesian Ͱ͋Δ͜ͱΛࣔͤ OK Promise Scala Ͱ͍͏ͱ͜Ζͷ Future ͔ͩΒ Monad Ұൠʹ Monad ) Applicative ) Cartesian ͳͷͰ OK ೦ͳ͓Βͤ ͜ͷਪେ͖ͳ͕݀͋Δ Javascript ͷ Promise Monad Ͱͳ͍ Functor Ͱ͢Βͳ͍ Cartesian ʹݟ͑Δͷଟۮવ
ݸਓతʹࢥ͍ͬͯΔ͜ͱ ؔܕͷߟ͑ํ͕ʮৗʹਖ਼͍͠ʯΘ͚ͳ͍ ͕ɼ ʮؔܕҎ֎ؔܕͷߟ͑ํ͕͑ͳ͍ʯͷ͔ʁ Ͳ͜·Ͱʢແཧͳ͘ʣ௨༻͢Δ͔ߟ͍͑ͨ ʢཧʣֶ͔Βٕज़ാʹೖͬͨࢲʹͱͬͯɼ ʮֶͬΆ͍ߟ͑ํ͕͑Δ͜ͱʯཧղΛ͛ Δ্Ͱେ͖ͳॿ͚ʹͳΔ
·ͱΊ Figure: Cats ͷΛ͠·ͨ͠ɽࣸਅ࣮ՈͷͶ͜Ͱ͢ɽ