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
PureScript
Search
Brian McKenna
May 19, 2014
Programming
590
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PureScript
For Full Stack Boulder.
Brian McKenna
May 19, 2014
More Decks by Brian McKenna
See All by Brian McKenna
Production PureScript
puffnfresh
0
130
Boulder Startup Week: What is functional programming?
puffnfresh
0
71
LambdaConf: Idris Workshop
puffnfresh
2
140
Other Decks in Programming
See All in Programming
GKE で Pod の見方を変えたら、スケールアウト時の挙動を真に捉えられた話
stkk
0
130
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
350
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
440
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
170
巨大モノリシックアプリ モダン化大作戦
ktcryomm
1
1k
App Storeの外へ──日本のiOSサイドローディング入門 for iOSDC Japan 2026
yuukiw00w
0
220
個人開発基盤をまるごとCloudflareに引っ越して爆速で総合的体験を向上させた話
tinykitten
0
190
SONY CISC-NEWS NWS-1750 + NWB-225 フレームバッファの NetBSD/news68k ドライバ実装 / OSC2026Hiroshima
tsutsui
0
120
『寄り添うラジオ』をAIで作る 体験価値から逆算した、会話しないUXと品質設計
theoriatec2024
3
180
Jetpack Compose メカニズム
skydoves
0
440
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
190
Family mrubyの進捗
kishima
1
130
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
540
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Building an army of robots
kneath
307
46k
Crafting Experiences
bethany
1
340
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
YesSQL, Process and Tooling at Scale
rocio
174
15k
New Earth Scene 8
popppiees
4
2.6k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
What does AI have to do with Human Rights?
axbom
PRO
1
2.4k
Six Lessons from altMBA
skipperchong
29
4.5k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Transcript
None
Goals
· Writing JavaScript · Functional programming · Small output ·
Small language
Transpilers Are Awesome
· Compile step! · ES6 is bad! · Small output,
take output and forget
Resources
· purescript.org · try.purescript.org · purescript.readthedocs.org
Types
data Person = Person String Number sayHello :: Person ->
String sayHello (Person name age) = "Hello " ++ name ++ ", you are " ++ show age ++ " years old"
var PS = PS || {}; PS.Person = (function ()
{ "use strict"; var Prelude = PS.Prelude; var Person = function (value0) { return function (value1) { return { ctor: "Person.Person", values: [ value0, value1 ] }; }; }; var sayHello = function (_1) { return "Hello " + _1.values[0] + ", you are " + Prelude.show(Prelude.showNumber({}))(_1.values[1]) + " years old"; }; return { Person: Person, sayHello: sayHello }; })();
var brian = PS.Person.Person("Brian")(24); console.log(PS.Person.sayHello(brian));
Extensible records
addXY :: forall r. { x :: Number, y ::
Number | r } -> Number addXY o = o.x + o.y -- Error: Object does not have property y -- x :: Number -- x = addXY { x: 1 } xy :: Number xy = addXY { x: 1, y: 2 } xyz :: Number xyz = addXY { x: 1, y: 2, z: 3 }
Interoperating
foreign import showBool "function showBool(b) {\ \ return b.toString();\ \}"
:: Boolean -> String
Type classes
class ToString s where toString :: s -> String instance
boolTS :: ToString Boolean where toString = showBool instance numberTS :: ToString Number where toString = showNumber main = trace (toString true ++ toString 10)
Tools
· npm · Grunt/Gulp · Bower
module.exports = function(grunt) { grunt.initConfig({ libFiles: [ "src/**/*.purs", "bower_components/purescript-*/src/**/*.purs", ],
clean: ["output"], pscMake: ["<%=libFiles%>"], dotPsci: ["<%=libFiles%>"], docgen: { readme: { src: "src/**/*.purs", dest: "README.md" } } }); grunt.loadNpmTasks("grunt-contrib-clean"); grunt.loadNpmTasks("grunt-purescript"); grunt.registerTask("make", ["pscMake", "dotPsci", "docgen"]); grunt.registerTask("default", ["make"]); };
{ "name": "purescript-streams", "homepage": "https://github.com/purescript-contrib/purescript-streams", "description": "Compositional, streaming I/O library",
"keywords": [ "purescript" ], "license": "MIT", "ignore": [ "**/.*", "bower_components", "node_modules", "output", "tests", "tmp", "bower.json", "Gruntfile.js", "package.json" ], "dependencies": { "purescript-monoid": ">=0.1.1", "purescript-tuples": "*", "purescript-task": "*" } }
Libraries
· purescript-react · purescript-reactive · purescript-canvas · purescript-jquery · purescript-quickcheck
· purescript-streams
counter = mkUI spec { getInitialState = return 0 }
do val <- readState return $ DOM.p { className: "Counter", onClick: handle incrementCounter } [ DOM.text (show val), DOM.text " Click me to increment!" ]
testConst :: Number -> Number -> Number -> Boolean testConst
a b c = const a b == const a c main :: Eff (trace :: Trace) {} main = quickCheck testConst
None
snowflake :: Number -> Drawing snowflake n = go <<<
go <<< go $ circle where go = everywhere replace replace (Arc { cx = cx, cy = cy, r = r }) = Composite $ flip map (range 0 (n - 1)) $ \i -> let theta = i / n * Math.pi * 2 in Arc { cx: cx + r * 0.7 * Math.sin theta , cy: cy + r * 0.7 * Math.cos theta , r: r * 0.3 , start: 0 , end: Math.pi * 2 } replace other = other
sayHello :: Process (Task (trace :: Trace)) {} sayHello =
await (traceTask "Hello") (const Halt) main :: Eff (trace :: Trace) {} main = runTask (Process.run (repeatedly sayHello))
· purescript.org · try.purescript.org · purescript.readthedocs.org