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
1.3k
ねことはじめる関数型 / functional programming with cats
VRC LT #7
ぷに
February 29, 2020
Tweet
Share
More Decks by ぷに
See All by ぷに
数値計算の呪いとあそぼぅ!!/ the curse of numerical calculus
punilfin
1
47
Other Decks in Technology
See All in Technology
10Xにおける品質保証活動の全体像と改善 #no_more_wait_for_test
nihonbuson
PRO
2
210
CDK対応したAWS DevOps Agentを試そう_20260201
masakiokuda
1
210
レガシー共有バッチ基盤への挑戦 - SREドリブンなリアーキテクチャリングの取り組み
tatsukoni
0
210
広告の効果検証を題材にした因果推論の精度検証について
zozotech
PRO
0
140
ブロックテーマ、WordPress でウェブサイトをつくるということ / 2026.02.07 Gifu WordPress Meetup
torounit
0
140
Agile Leadership Summit Keynote 2026
m_seki
1
530
SREのプラクティスを用いた3領域同時 マネジメントへの挑戦 〜SRE・情シス・セキュリティを統合した チーム運営術〜
coconala_engineer
2
610
usermode linux without MMU - fosdem2026 kernel devroom
thehajime
0
220
外部キー制約の知っておいて欲しいこと - RDBMSを正しく使うために必要なこと / FOREIGN KEY Night
soudai
PRO
12
4.9k
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
3k
GitLab Duo Agent Platform × AGENTS.md で実現するSpec-Driven Development / GitLab Duo Agent Platform × AGENTS.md
n11sh1
0
120
ファインディの横断SREがTakumi byGMOと取り組む、セキュリティと開発スピードの両立
rvirus0817
1
1.2k
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.7k
Designing Experiences People Love
moore
144
24k
Scaling GitHub
holman
464
140k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
So, you think you're a good person
axbom
PRO
2
1.9k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
430
GitHub's CSS Performance
jonrohan
1032
470k
Making Projects Easy
brettharned
120
6.6k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
300
sira's awesome portfolio website redesign presentation
elsirapls
0
140
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
How to Ace a Technical Interview
jacobian
281
24k
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 ͷΛ͠·ͨ͠ɽࣸਅ࣮ՈͷͶ͜Ͱ͢ɽ