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
810
怖くない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
930
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
For a Future-Friendly Web
brad_frost
178
9.7k
Practical Orchestrator
shlominoach
188
11k
Optimising Largest Contentful Paint
csswizardry
37
3.3k
Facilitating Awesome Meetings
lara
54
6.4k
Unsuck your backbone
ammeep
671
58k
Fireside Chat
paigeccino
37
3.5k
Why Our Code Smells
bkeepers
PRO
336
57k
How to Think Like a Performance Engineer
csswizardry
23
1.6k
Optimizing for Happiness
mojombo
378
70k
VelocityConf: Rendering Performance Case Studies
addyosmani
329
24k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
The Language of Interfaces
destraynor
158
25k
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エンジニアとして学んでいて楽しい。 ▪ 汎用的で腐りにくい抽象化の知識。 • とはいえ、濫用には注意 ◦ 使ったほうがコードが理解しやすい / 堅牢になるといった場面で使うべき。 ▪ 『ハンマーを持つ人には全てが釘に見える』に注意。 ◦ 自分やチームメンバーの理解を超えて使わない。 ▪ 無理して使うものではない。