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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
320
Other Decks in Technology
See All in Technology
こんなところでも(地味に)活躍するImage Modeさんを知ってるかい?- Image Mode for OpenShift -
tsukaman
0
100
AzureでのIaC - Bicep? Terraform? それ早く言ってよ会議
torumakabe
1
400
Bill One 開発エンジニア 紹介資料
sansan33
PRO
4
17k
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.3k
FinTech SREのAWSサービス活用/Leveraging AWS Services in FinTech SRE
maaaato
0
120
GSIが複数キー対応したことで、俺達はいったい何が嬉しいのか?
smt7174
3
140
CDK対応したAWS DevOps Agentを試そう_20260201
masakiokuda
1
200
小さく始めるBCP ― 多プロダクト環境で始める最初の一歩
kekke_n
1
360
月間数億レコードのアクセスログ基盤を無停止・低コストでAWS移行せよ!アプリケーションエンジニアのSREチャレンジ💪
miyamu
0
810
Introduction to Bill One Development Engineer
sansan33
PRO
0
360
モダンUIでフルサーバーレスなAIエージェントをAmplifyとCDKでサクッとデプロイしよう
minorun365
3
150
Oracle Cloud Observability and Management Platform - OCI 運用監視サービス概要 -
oracle4engineer
PRO
2
14k
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
90
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
82
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
220
Navigating Team Friction
lara
192
16k
Side Projects
sachag
455
43k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.7k
Building Adaptive Systems
keathley
44
2.9k
The Curse of the Amulet
leimatthew05
1
8.3k
Code Reviewing Like a Champion
maltzj
527
40k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
110
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?