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
Let's talk about PureScript
Search
Kārlis Lauva
August 17, 2016
Programming
0
77
Let's talk about PureScript
Presentation at Frontend Meetup Riga, August 2016.
Kārlis Lauva
August 17, 2016
Tweet
Share
More Decks by Kārlis Lauva
See All by Kārlis Lauva
Going Full Monty with full.monty
karlis
1
93
The Transatlantic Struggle
karlis
0
66
Two Scoops of Scala
karlis
0
100
Valsts pārvaldes atvērto datu semantiskās integrācijas procesi
karlis
1
170
Tornado in 1 Hour (or Less)
karlis
4
190
Other Decks in Programming
See All in Programming
AI駆動のマルチエージェントによる業務フロー自動化の設計と実践
h_okkah
0
250
Hack Claude Code with Claude Code
choplin
8
2.7k
Android 16KBページサイズ対応をはじめからていねいに
mine2424
0
500
テスターからテストエンジニアへ ~新米テストエンジニアが歩んだ9ヶ月振り返り~
non0113
2
230
はじめてのWeb API体験 ー 飲食店検索アプリを作ろうー
akinko_0915
0
150
ソフトウェア設計とAI技術の活用
masuda220
PRO
22
6k
AI時代のソフトウェア開発を考える(2025/07版) / Agentic Software Engineering Findy 2025-07 Edition
twada
PRO
99
38k
MySQL9でベクトルカラム登場!PHP×AWSでのAI/類似検索はこう変わる
suguruooki
1
140
チームで開発し事業を加速するための"良い"設計の考え方 @ サポーターズCoLab 2025-07-08
agatan
1
480
Streamlitで実現できるようになったこと、実現してくれたこと
ayumu_yamaguchi
2
120
Claude Code派?Gemini CLI派? みんなで比較LT会!_20250716
junholee
1
630
Jakarta EE Meets AI
ivargrimstad
0
130
Featured
See All Featured
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.2k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.5k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Bash Introduction
62gerente
613
210k
The Invisible Side of Design
smashingmag
301
51k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
47
9.6k
The Art of Programming - Codeland 2020
erikaheidi
54
13k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
18
1k
For a Future-Friendly Web
brad_frost
179
9.8k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
7
750
Statistics for Hackers
jakevdp
799
220k
4 Signs Your Business is Dying
shpigford
184
22k
Transcript
an exciting trip through history prelude
1936 Lambda Calculus is born
1990 A bunch of smart people start working Haskell
1995 Brendan Eich is hired by NetScape to write Scheme
for the browser
Spoiler alert: He doesn't write a Scheme for NetScape
2016
You shouldn't be sad.
Maybe those functional dudes got something right.
let's talk about purescript Kārlis Lauva @skazhy frontend rīga meetup,
2016
Hello. I write Clojure and dabble with other things This
is not a monad tutorial This is, like, my opinion
So, Haskell for the browser, eh
module Main where import Prelude import Control.Monad.Eff import Control.Monad.Eff.Console sup
:: String -> String sup g = "sup, " ++ g main :: forall e. Eff (console :: CONSOLE | e) Unit main = do log $ sup "world"
None
(function(exports) { "use strict"; var Prelude = PS["Prelude"]; var Control_Monad_Eff
= PS["Control.Monad.Eff"]; var Control_Monad_Eff_Console = PS["Control.Monad.Eff.Console"]; var sup = function (g) { return "sup, " + g; }; var main = Control_Monad_Eff_Console.log(sup("world")); exports["main"] = main; exports["sup"] = sup;; })(PS["Main"] = PS["Main"] || {}); PS["Main"].main();
Y
turns out, functional programming languages are really useful for web
things
but javascript too can be purely functional
None
let's discuss the bad parts
[Object object]
an *actual* type system
purescript makes this example boring
like, really boring
sketchy branching
None
None
pattern matching
data Behavior = KillHumans | BeNiceToHumans type Robot = {
naughty :: Boolean } interactWithHumans :: Robot -> Behavior interactWithHumans { naughty: true } = KillHumans interactWithHumans { naughty: false } = BeNiceToHumans
data Behavior = KillAllHumans | BeNiceToHumans | KillOnlyVapers type Robot
= { niceness :: Int } interactWithHumans :: Robot -> Behavior interactWithHumans { niceness: 0 } = KillAllHumans interactWithHumans { niceness: 1 } = KillOnlyVapers interactWithHumans _ = BeNiceToHumans
callback hell
monads
fetchRobots(function(response) { assembleFleet(function(robots) { if (robots) return robots; }, function(error
{ .. }); }, function(error) {... });
data RobotArmy = Army (List Robot) fetchRobots = do robotParts
<- get "/robotParts" robots <- assembleFleet robotParts return $ Army robots
None
does purescript survive in the real world?
yes.
None
ecosystem and tooling
psc short for "purescript compiler"
modules managed via bower
• build tool => pulp • hoogle for purescript =>
pursuit
purescript - javascript teamwork
back to killer robots
data Behavior = KillHumans | BeNiceToHumans instance showBehavior :: Show
Behavior where show KillHumans = "kill all humans11" show BeNiceToHumans = "humans, you are pretty tite" type Robot = { naughty :: Boolean } interactWithHumans :: Robot -> Behavior interactWithHumans { naughty: true } = KillHumans interactWithHumans { naughty: false } = BeNiceToHumans safeInteract :: Boolean -> String safeInteract x = show $ interactWithHumans { crazyMurderer : x }
PS.Main.safeInteract(isCrazyMurderingRobot)();
but will purescript react?
yes.
ok, so what have we learned
so should we all switch to purescript today?
not _all_ of us
most of the internet runs on vanilla javascript just fine
(for years)
None
None
go check it out hack cool things
• purescript.org • karlis.me
thanks