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
72
LambdaConf: Idris Workshop
puffnfresh
2
140
Other Decks in Programming
See All in Programming
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
470
SONY CISC-NEWS NWS-1750 + NWB-225 フレームバッファの NetBSD/news68k ドライバ実装 / OSC2026Hiroshima
tsutsui
0
160
モジュールの視点からSwiftを読み解く #iosdc
s_shimotori
0
300
TiDB Cloudのカスタムコントローラーによるオートスケール対応
takaidohigasi
0
140
Simple Storage Service(S3) is not simple
iwatsukayura
0
120
Workers Cache を知る
syumai
0
320
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
750
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
3.1k
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
0
150
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
8
5.3k
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
460
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
200
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.9k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Google's AI Overviews - The New Search
badams
0
1.6k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
How Software Deployment tools have changed in the past 20 years
geshan
2
34k
Tell your own story through comics
letsgokoyo
1
1.1k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
390
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
590
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
440
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