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
76
0
Share
PureScript.tw Meetup 2: Tutorial 2
Range: Ch6 of the book PureScript by Example
Ray Shih
April 28, 2017
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
遊びで始めたNew Relic MCP、気づいたらChatOpsなオブザーバビリティボットができてました/From New Relic MCP to a ChatOps Observability Bot
aeonpeople
1
150
Cortex Codeでデータの仕事を全部Agenticにやりきろう!
gappy50
0
110
ハーネスエンジニアリング×AI適応開発
aictokamiya
3
1.3k
MCPで決済に楽にする
mu7889yoon
0
170
会社紹介資料 / Sansan Company Profile
sansan33
PRO
16
410k
ThetaOS - A Mythical Machine comes Alive
aslander
0
230
マルチモーダル非構造データとの闘い
shibuiwilliam
1
130
Oracle Cloud Infrastructure(OCI):Onboarding Session(はじめてのOCI/Oracle Supportご利⽤ガイド)
oracle4engineer
PRO
2
17k
互換性のある(らしい)DBへの移行など考えるにあたってたいへんざっくり
sejima
PRO
0
520
スケーリングを封じられたEC2を救いたい
senseofunity129
0
130
20260323_データ分析基盤でGeminiを使う話
1210yuichi0
0
210
Oracle Cloud Infrastructure:2026年3月度サービス・アップデート
oracle4engineer
PRO
0
300
Featured
See All Featured
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
140
What does AI have to do with Human Rights?
axbom
PRO
1
2.1k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
190
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
110
Designing Powerful Visuals for Engaging Learning
tmiket
1
320
Test your architecture with Archunit
thirion
1
2.2k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
940
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
860
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
320
Designing Experiences People Love
moore
143
24k
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?