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
怖くないCats
Search
Jun Tomioka
October 15, 2018
0
800
怖くないCats
Jun Tomioka
October 15, 2018
Tweet
Share
More Decks by Jun Tomioka
See All by Jun Tomioka
Dotty で軽量な DI ライブラリをかいてみた
jooohn
1
330
ソフトウェアエンジニアとしてモナドを完全に理解する / make-perfect-sense-of-monad
jooohn
14
7.7k
ScalaのコンパイラにFizzBuzzを解いてもらう(Dottyもあるよ)
jooohn
1
1k
Write stack safe non-tailrec recursive functions
jooohn
4
920
Introduction to Clean Architecture
jooohn
1
550
人類には早すぎる、謎の計算ロジックに立ち向かう / Strugle with the most complicated logic ever
jooohn
1
1.7k
Work at M3 USA
jooohn
0
1.3k
クラウド電子カルテを支えるテクノロジーの光と闇
jooohn
0
1.3k
Scalaの型クラスを完全に理解する
jooohn
5
1.9k
Featured
See All Featured
Adopting Sorbet at Scale
ufuk
76
9.4k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.5k
Statistics for Hackers
jakevdp
799
220k
Bash Introduction
62gerente
613
210k
Stop Working from a Prison Cell
hatefulcrawdad
268
20k
YesSQL, Process and Tooling at Scale
rocio
172
14k
4 Signs Your Business is Dying
shpigford
183
22k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2k
Building Adaptive Systems
keathley
41
2.5k
KATA
mclloyd
29
14k
Into the Great Unknown - MozCon
thekraken
38
1.8k
For a Future-Friendly Web
brad_frost
177
9.7k
Transcript
怖くない Cats @jooohn1234
M3, Inc. @jooohn1234 • じょん と呼んでください • エムスリーのエンジニア ◦ Scala
・ FP 好き ◦ 猫2匹と同居
None
None
None
None
None
None
None
None
None
モナドは プログラム可能な セミコロン!!
やばい世界に 足を踏み入れて しまった
None
None
None
None
完全にこわい
None
None
None
None
None
None
None
None
None
None
Catsは 怖くない!
Motivations • Approachability • Modularity • Documentation • Efficiency
Motivations • Approachability • Modularity • Documentation • Efficiency
Motivations • Approachability • Modularity • Documentation • Efficiency ドキュメントが充実していて
とっつきやすい!
Monoid
None
None
None
None
None
二項演算 (Int, Int) => Int 単位元 Int
二項演算 (Int, Int) => Int 単位元 Int こういう感じの性質を 持っているやつが Monoid
注:ざっくりした説明です
例でなんとなく理解するMonoid (厳密には Monoid lawsを参照) Monoid 単位元 (empty) 二項演算 (combine) 例
Int の 加算 0 + 0 + 1 + 2 + 0 = 3 Int の 乗算 1 * 1 * 3 * 5 * 1 = 15 List の 連結 Nil ::: Nil ::: List(3) ::: List(5, 8) ::: Nil = List(3, 5, 8)
Monoid laws law Intの加算 の例 (a combine b) combine c
= a combine (b combine c) (1 + 2) + 3 = 6 1 + (2 + 3) = 6 empty combine a = a 0 + 1234 = 1234 a combine empty = a 1234 + 0 = 1234
なんかわかるきがする!
・・・
それで なにがうれしいんだっけ
None
None
None
None
みたことあるきがする
None
None
こういうときある
こういうときある
None
なんかややこしい
None
Monoidはつくれる!
None
全てのMonoidに対して Foldable#foldMapが使える
None
・・・
ほとんど Int と同じなのに めんどうだなあ
None
None
None
Int と Price は値を変えずに交換可能
None
None
None
None
None
None
便利!
雑感 • Cats は怖くないし便利! ◦ Approachability / Documentation ▪ ドキュメントを読み進めながら学習が進む。
◦ 便利と思ったものだけ使えば良い ▪ 自分やチームの成長とともに徐々に扱う範囲を増やしていける。 ◦ 1エンジニアとして学んでいて楽しい。 ▪ 汎用的で腐りにくい抽象化の知識。 • とはいえ、濫用には注意 ◦ 使ったほうがコードが理解しやすい / 堅牢になるといった場面で使うべき。 ▪ 『ハンマーを持つ人には全てが釘に見える』に注意。 ◦ 自分やチームメンバーの理解を超えて使わない。 ▪ 無理して使うものではない。