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
PureScript.tw Meetup 2: Tutorial 2
Search
Ray Shih
April 28, 2017
Technology
0
74
PureScript.tw Meetup 2: Tutorial 2
Range: Ch6 of the book PureScript by Example
Ray Shih
April 28, 2017
Tweet
Share
More Decks by Ray Shih
See All by Ray Shih
From React To PureScript
rayshih
0
310
Other Decks in Technology
See All in Technology
Click A, Buy B: Rethinking Conversion Attribution in ECommerce Recommendations
lycorptech_jp
PRO
0
110
Zephyr(RTOS)にEdge AIを組み込んでみた話
iotengineer22
0
220
Kubernetes self-healing of your workload
hwchiu
0
300
Implementing and Evaluating a High-Level Language with WasmGC and the Wasm Component Model: Scala’s Case
tanishiking
0
150
混合雲環境整合異質工作流程工具運行關鍵業務 Job 的經驗分享
yaosiang
0
110
ニッポンの人に知ってもらいたいGISスポット
sakaik
0
190
組織改革から開発効率向上まで! - 成功事例から見えたAI活用のポイント - / 20251016 Tetsuharu Kokaki
shift_evolve
PRO
2
210
dbtとBigQuery MLで実現する リクルートの営業支援基盤のモデル開発と保守運用
recruitengineers
PRO
3
150
NLPコロキウム20251022_超効率化への挑戦: LLM 1bit量子化のロードマップ
yumaichikawa
1
120
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.2k
SCONE - 動画配信の帯域を最適化する新プロトコル
kazuho
1
270
Data Hubグループ 紹介資料
sansan33
PRO
0
2.2k
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
331
21k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
Producing Creativity
orderedlist
PRO
347
40k
YesSQL, Process and Tooling at Scale
rocio
173
14k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
How to Ace a Technical Interview
jacobian
280
24k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
127
54k
Being A Developer After 40
akosma
91
590k
Designing for Performance
lara
610
69k
Raft: Consensus for Rubyists
vanstee
140
7.2k
Transcript
PureScript Tutorial 2 Ray Shih
Chapter 6~ See how far we can go
Chapter 6: Type Classes • Similar to Java interface •
Show • Monoid, Foldable -> foldMap • Functor • Function constraint • Multi Parameter Type Classes • Nullary Type Class • Superclass
The Class & The Instance
Instance Dependencies
Common type classes
Semigroup, Monoid
Foldable
Functor
Function is a Functor!!! What?
Multi Parameter type class
Nullary type class
Congratulation! That’s all!
Congratulation! That’s all…. the syntax you need (almost)
Challenge! • Try to create a function `printf` which can
print out arbitrary number of arguments • printf “Hello” “World” • printf “a = “ 3 • printf a “ + “ b “ = “ (a + b)
Chapter 7: Applicative Validation • Control.Apply, lift3 on Maybe •
type class Apply • type class Applicative • Maybe -> Either: withError • combineList • purescript-validation (skip) • Traversable Functor • Parallelism
Control.Apply
type class Apply
instance applyMaybe
type class Applicative
Revisit lift3
Maybe -> Either withError
withError example
combineList
Traversable Functor
Parallelism
Chapter 8: The Eff Monad • Do notation revisited •
XML traverse • The Monad Type Class • Monad Law (skip) • Folding With Monads • Monads and Applicative • Eff Monad
Do notation
XML traverse
The Monad Type Class
Monad instances
What `do` really do?
Reveal the XML parsing example
Folding with Monads
Folding with Monad example
FoldM exercise • (Medium) Write a function sums which uses
foldM to determine all possible totals that could be made using a set of coins. The coins will be specified as an array which contains the value of each coin. Your function should have the following result.
Monads and Applicatives • Of course, Monad is a Applicative
• But Monad is more than Applicative
Eff Monad
The type of Eff
Fine-Grained Effects
Next? • Frontend Pux? • Backend? • React Native? •
Chapter 11: Monadic Adventures? • Lenses? • PureScript 24 days?