Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Let's talk about PureScript
Search
Kārlis Lauva
August 17, 2016
Programming
95
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Let's talk about PureScript
Presentation at Frontend Meetup Riga, August 2016.
Kārlis Lauva
August 17, 2016
More Decks by Kārlis Lauva
See All by Kārlis Lauva
Going Full Monty with full.monty
karlis
1
120
The Transatlantic Struggle
karlis
0
93
Two Scoops of Scala
karlis
0
130
Valsts pārvaldes atvērto datu semantiskās integrācijas procesi
karlis
1
220
Tornado in 1 Hour (or Less)
karlis
4
210
Other Decks in Programming
See All in Programming
Webの地図
yosuke_furukawa
PRO
6
5.1k
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
150
プロダクトコードからライブラリの境界を見つける
elmetal
PRO
0
100
FreeBSDでZabbixを動かす
kenkino
0
360
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.5k
機械に任せるテスト、人が見るテスト ⽣成AIで引き直した、運⽤保守フェーズの線引き
dske104
0
160
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
350
Workers Cache を知る
syumai
0
330
wkhtmltopdfの次どうするか問題2026
willnet
2
1.8k
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
34
15k
Domain-Driven Transformation
hschwentner
2
2.3k
SalesForceを内製化!? ~ HR事業を支える顧客管理基盤のインフラを大公開 ~
oku053
0
120
Featured
See All Featured
Technical Leadership for Architectural Decision Making
baasie
3
590
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
A better future with KSS
kneath
240
18k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
540
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.1k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
350
WENDY [Excerpt]
tessaabrams
14
40k
How GitHub (no longer) Works
holman
316
150k
Raft: Consensus for Rubyists
vanstee
142
7.7k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
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