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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
13k
Amazon Bedrock Knowledge Basesチャンキング解説!
aoinoguchi
0
140
StrandsとNeptuneを使ってナレッジグラフを構築する
yakumo
1
110
10Xにおける品質保証活動の全体像と改善 #no_more_wait_for_test
nihonbuson
PRO
2
240
MCPでつなぐElasticsearchとLLM - 深夜の障害対応を楽にしたい / Bridging Elasticsearch and LLMs with MCP
sashimimochi
0
160
SREチームをどう作り、どう育てるか ― Findy横断SREのマネジメント
rvirus0817
0
220
学生・新卒・ジュニアから目指すSRE
hiroyaonoe
2
590
データの整合性を保ちたいだけなんだ
shoheimitani
8
3.1k
AI駆動開発を事業のコアに置く
tasukuonizawa
1
170
顧客との商談議事録をみんなで読んで顧客解像度を上げよう
shibayu36
0
220
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1k
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.3k
Featured
See All Featured
Producing Creativity
orderedlist
PRO
348
40k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
Speed Design
sergeychernyshev
33
1.5k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
Mind Mapping
helmedeiros
PRO
0
81
ラッコキーワード サービス紹介資料
rakko
1
2.3M
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.1k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
200
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
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?