SlideShare a Scribd company logo
1 of 36
Download to read offline
Getting Started with
PureScript
John A. De Goes
Agenda
• Introduction
• What is PureScript
• Syntax & Semantics
• Who Uses PureScript
• Why PureScript
• Ecosystem
• Getting Started
• Node.js
• NPM
• Bower
• PureScript
• Pulp
• Hello World
What is PureScript?
PureScript is a strongly-typed, purely-functional programming
language that compiles to Javascript1
, and is written in and
inspired by Haskell.
1
And C++!
Syntax
import Control.Apply
import Graphics.Canvas.Free
scene =
filled $ closed do
moveTo 0 0
lineTo 50 0
lineTo 25 50
where
closed path = beginPath *> path <* closePath
filled shape = shape <* fill
Semantics
• Type Inference
• Higher-Kinded Polymorphism
• Support for basic Javascript types
• Extensible records
• Extensible effects
• Optimizer rules for generation of efficient Javascript
• Pattern matching
• Simple FFI
• Modules
• Rank N Types
• Do Notation
• Tail-call elimination
• Type Classes
Who Uses PureScript?2
• SlamData
• Xamarin
• DICOM Grid
• Middlebury Interactive Languages
• DICE.fm
• McGraw Hill Financial
2
Cobbled together from various online sources.*
Why PureScript?
Motivation
• You want to or are forced to do front-end or node.js
• You like static typing
• You like functional programming, of the pure variety
• You prefer expressive power over no-frills, opinionated simplicity
• You want to crush Javascript/CoffeeScript/TypeScript/Scala3
beneath your
heel... BWAHAHA!
3
OK, not quite yet.
Why PureScript?
..instead of GHCJS?
• "Haskell in hindsight"
• Strict versus lazy
• Zero runtime
• Clean, easy FFI
• Great re-use of third-party JS
• Simpler language than GHC's quadrillion dialects of Haskell
Ecosystem
Ecosystem
UI Libraries
• purescript-halogen
• purescript-react
• purescript-angular
• purescript-rx
• purescript-flare
• purescript-pux
• purescript-optic-ui
• purescript-behaviors
• purescript-signal
• purescript-thermite
• purescript-frp-rabbit
• purescript-sigment
• purescript-ufi
And even more!
Ecosystem
Testing Libraries
• purescript-test-unit
• purescript-quickcheck
• purescript-quickcheck-laws
• purescript-strongcheck
• purescript-benchotron
• purescript-spec
• purescript-assert
Ecosystem
Preludes4
• purescript-prelude
• purescript-preface
• purescript-batteries
4
Yes, there are multiple!
Ecosystem
Build Tooling
• pulp
• grunt-purescript
• gulp-purescript
• purescript-psa
Ecosystem
Editor / IDE Support
• Atom
• purescript-contrib/atom-language-purescript
• nwolverson/atom-ide-purescript
• Emacs
• dysinger/purescript-mode
• emacs-pe/purescript-mode
• ardumont/psci-mode
• spion/purscheck
• emacs-pe/flycheck-purescript
• epost/psc-ide-emacs
• Sublime Text 2 - PureScript package
• Vim
• purescript-vim
• FrigoEU/psc-ide-vim
• IntelliJ IDEA - ikarienator/pure-idea
• Visual Studio - nwolverson/vscode-ide-purescript
• General
• kRITZCREEK/psc-ide
• To generate TAGS files, use psc-docs --format etags (or --format ctags)
Ecosystem
Library Search
Pursuit
Getting Started
Prerequisites
1. Node.js
2. NPM
3. Bower
4. PureScript
5. Pulp
Getting Started
Prerequisites: Node.js
Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript
engine. Node.js uses an event-driven, non-blocking I/O model
that makes it lightweight and efficient. Node.js' package
ecosystem, npm, is the largest ecosystem of open source libraries
in the world.
Node.js allows full-featured, browser-less Javascript
programs.
Getting Started
Prerequisites: Node.js
• Many Javascript dev tools are written in Javascript and run
on Node.js
• PureScript dev tools are written in PureScript, compiled to
JavaScript
• Bottom Line: You can't live without it (even if you want to!).
Getting Started
Prerequisites: Node.js
• Installers
https://nodejs.org/en/download/
• Homebrew
brew install node
• MacPorts
port install nodejs
• pkgsrc
pkgin -y install nodejs
• Debian / Ubunutu (4.x)
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
• Debian / Ubuntu (6.x)
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
Getting Started
Prerequisites: NPM
• NPM = Node Package Manager
• Used by Node to manage packages
• Many tools and libraries are distributed through NPM
• Bottom Line: Another thing you can't live without...
Getting Started
Prerequisites: NPM
• NPM comes pre-installed with Node.js but version may be
old
• Self-Updating NPM:
sudo npm install npm -g
Getting Started
Prerequisites: Bower
• A package manager for the web
• Maintains global registry of name -> URL
• Supports repositories & tags
• Supports all types of dependencies (binary, PureScript, etc.)
• Dependencies specified in bower.json file
• Bottom Line: Almost all PureScript libraries are registered with bower,
and almost all PureScript projects maintain dependencies with bower!
Getting Started
Prerequisites: Bower
{
"name": "purescript-library",
"description": "A PureScript library",
"authors": [
"John A. De Goes <john@degoes.net>"
],
"license": "Apache 2",
"version": "0.1.0",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"output"
],
"dependencies": {
"purescript-profunctor-lenses": "^1.0.0-rc.1",
"purescript-free": "^1.0.0-rc.1",
"purescript-console": "^v1.0.0-rc.1",
"purescript-either": "^v1.0.0-rc.1",
"purescript-maybe": "^1.0.0-rc.1",
"purescript-foldable-traversable": "^1.0.0-rc.1",
"purescript-monoid": "^1.0.0-rc.2",
"purescript-bifunctors": "^1.0.0-rc.1",
"purescript-invariant": "^1.0.0-rc.1",
"purescript-prelude": "^1.0.0-rc.4",
"purescript-control": "^1.0.0-rc.1",
"purescript-transformers": "^1.0.0-rc.1"
}
}
Getting Started
Prerequisites: Bower
• Install with NPM
npm install -g bower
Getting Started
Prerequisites: PureScript Compiler
• psc — PureScript compiler
• psc-docs — PureScript documentation generator
• psc-bundle — Bundler & dead-code eliminator
• psci — PureScript Read-Eval-Print-Loop (REPL)
• psc-ide-server — IDE Server
• psc-ide-client — IDE Client
Getting Started
Prerequisites: PureScript Compiler
• Installers
https://github.com/purescript/purescript/releases/latest
• Install with NPM
npm install -g purescript
Getting Started
Prerequisites: Pulp
• Pulp: Popular build tool for PureScript projects
• Knows how to perform magical incantations of psc & related
tools
• Bottom Line: If you can use it to build your project, then do
it!
Getting Started
Prerequisites: Pulp
• Install with NPM
npm install -g pulp
Getting Started
Hello World
1. Create Directory Structure
2. Create Bower File
3. Install Bower Dependencies
4. Write PureScript Main
5. Build & Run
Getting Started
Hello World: Create Directory Structure
bower.json
/src/
/Main.purs
Getting Started
Hello World: Create Bower File
{
"name": "hello world",
"dependencies": {
"purescript-console": "^0.1.1",
"purescript-eff": "^0.1.2",
"purescript-prelude": "^0.1.5"
}
}
Getting Started
Hello World: Install Bower Dependencies
bower install
Getting Started
Hello World: Write PureScript Main
module Main where
import Prelude(Unit)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log)
main :: forall e. Eff (console :: CONSOLE | e) Unit
main = do
log "Hello World!"
Getting Started
Hello World: Build & Run
pulp build
pulp run
Congratulations, You've Started Your Journey Into The
World of PureScript!
Don't Forget the Easy Peasy PureScript Workshop at LambdaConf 2016!
More Resources: http://purescript.org
THE END

More Related Content

What's hot

自分をClojure化する方法
自分をClojure化する方法自分をClojure化する方法
自分をClojure化する方法
fukamachi
 

What's hot (18)

RSYSLOG v8 improvements and how to write plugins in any language.
RSYSLOG v8 improvements and how to write plugins in any language.RSYSLOG v8 improvements and how to write plugins in any language.
RSYSLOG v8 improvements and how to write plugins in any language.
 
Philly Tech Week Introduction to NodeJS
Philly Tech Week Introduction to NodeJSPhilly Tech Week Introduction to NodeJS
Philly Tech Week Introduction to NodeJS
 
Dive into sentry
Dive into sentryDive into sentry
Dive into sentry
 
Lisp Meet Up #31, Clake: a GNU make-like build utility in Common Lisp
Lisp Meet Up #31, Clake: a GNU make-like build utility in Common LispLisp Meet Up #31, Clake: a GNU make-like build utility in Common Lisp
Lisp Meet Up #31, Clake: a GNU make-like build utility in Common Lisp
 
Node.js Workshop - Sela SDP 2015
Node.js Workshop  - Sela SDP 2015Node.js Workshop  - Sela SDP 2015
Node.js Workshop - Sela SDP 2015
 
Initiation à Ruby on Rails
Initiation à Ruby on RailsInitiation à Ruby on Rails
Initiation à Ruby on Rails
 
Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in Nodejs
 
Nodejs vatsal shah
Nodejs vatsal shahNodejs vatsal shah
Nodejs vatsal shah
 
Testing Wi-Fi with OSS Tools
Testing Wi-Fi with OSS ToolsTesting Wi-Fi with OSS Tools
Testing Wi-Fi with OSS Tools
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
Dockercon Swarm Updated
Dockercon Swarm UpdatedDockercon Swarm Updated
Dockercon Swarm Updated
 
自分をClojure化する方法
自分をClojure化する方法自分をClojure化する方法
自分をClojure化する方法
 
Mobile Analytics mit Elasticsearch und Kibana
Mobile Analytics mit Elasticsearch und KibanaMobile Analytics mit Elasticsearch und Kibana
Mobile Analytics mit Elasticsearch und Kibana
 
Don’t turn your logs into cuneiform
Don’t turn your logs into cuneiformDon’t turn your logs into cuneiform
Don’t turn your logs into cuneiform
 
Ansible+docker (highload++2015)
Ansible+docker (highload++2015)Ansible+docker (highload++2015)
Ansible+docker (highload++2015)
 
vert.x 3.1 - be reactive on the JVM but not only in Java
vert.x 3.1 - be reactive on the JVM but not only in Javavert.x 3.1 - be reactive on the JVM but not only in Java
vert.x 3.1 - be reactive on the JVM but not only in Java
 
Kubernetes #4 volume &amp; stateful set
Kubernetes #4   volume &amp; stateful setKubernetes #4   volume &amp; stateful set
Kubernetes #4 volume &amp; stateful set
 
vert.x 소개 및 개발 실습
vert.x 소개 및 개발 실습vert.x 소개 및 개발 실습
vert.x 소개 및 개발 실습
 

Similar to Getting Started with PureScript

Practical introduction to dev ops with chef
Practical introduction to dev ops with chefPractical introduction to dev ops with chef
Practical introduction to dev ops with chef
LeanDog
 
201304 chef for open stack overview
201304 chef for open stack overview201304 chef for open stack overview
201304 chef for open stack overview
OpenStack Foundation
 
201304 chef for open stack overview
201304 chef for open stack overview201304 chef for open stack overview
201304 chef for open stack overview
OpenStack Foundation
 

Similar to Getting Started with PureScript (20)

FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101
 
The tools & technologies behind Resin.io
The tools & technologies behind Resin.ioThe tools & technologies behind Resin.io
The tools & technologies behind Resin.io
 
Leonid Vasilyev "Building, deploying and running production code at Dropbox"
Leonid Vasilyev  "Building, deploying and running production code at Dropbox"Leonid Vasilyev  "Building, deploying and running production code at Dropbox"
Leonid Vasilyev "Building, deploying and running production code at Dropbox"
 
Practical introduction to dev ops with chef
Practical introduction to dev ops with chefPractical introduction to dev ops with chef
Practical introduction to dev ops with chef
 
Intro to CakePHP
Intro to CakePHPIntro to CakePHP
Intro to CakePHP
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Lions, Tigers and Deers: What building zoos can teach us about securing micro...
Lions, Tigers and Deers: What building zoos can teach us about securing micro...Lions, Tigers and Deers: What building zoos can teach us about securing micro...
Lions, Tigers and Deers: What building zoos can teach us about securing micro...
 
Dcjq node.js presentation
Dcjq node.js presentationDcjq node.js presentation
Dcjq node.js presentation
 
Expert JavaScript Programming
Expert JavaScript ProgrammingExpert JavaScript Programming
Expert JavaScript Programming
 
Fluo CICD OpenStack Summit
Fluo CICD OpenStack SummitFluo CICD OpenStack Summit
Fluo CICD OpenStack Summit
 
SCALE12X: Chef for OpenStack
SCALE12X: Chef for OpenStackSCALE12X: Chef for OpenStack
SCALE12X: Chef for OpenStack
 
Chef For OpenStack Overview
Chef For OpenStack OverviewChef For OpenStack Overview
Chef For OpenStack Overview
 
201304 chef for open stack overview
201304 chef for open stack overview201304 chef for open stack overview
201304 chef for open stack overview
 
201304 chef for open stack overview
201304 chef for open stack overview201304 chef for open stack overview
201304 chef for open stack overview
 
Chef for OpenStack: OpenStack Spring Summit 2013
Chef for OpenStack: OpenStack Spring Summit 2013Chef for OpenStack: OpenStack Spring Summit 2013
Chef for OpenStack: OpenStack Spring Summit 2013
 
Open Source Swift Under the Hood
Open Source Swift Under the HoodOpen Source Swift Under the Hood
Open Source Swift Under the Hood
 
Engage 2019: Introduction to Node-Red
Engage 2019: Introduction to Node-RedEngage 2019: Introduction to Node-Red
Engage 2019: Introduction to Node-Red
 
Holy PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood editionHoly PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood edition
 
Everything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPLEverything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPL
 
Everything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureEverything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventure
 

More from John De Goes

Refactoring Functional Type Classes
Refactoring Functional Type ClassesRefactoring Functional Type Classes
Refactoring Functional Type Classes
John De Goes
 
The Death of Final Tagless
The Death of Final TaglessThe Death of Final Tagless
The Death of Final Tagless
John De Goes
 
Orthogonal Functional Architecture
Orthogonal Functional ArchitectureOrthogonal Functional Architecture
Orthogonal Functional Architecture
John De Goes
 
Post-Free: Life After Free Monads
Post-Free: Life After Free MonadsPost-Free: Life After Free Monads
Post-Free: Life After Free Monads
John De Goes
 

More from John De Goes (20)

Refactoring Functional Type Classes
Refactoring Functional Type ClassesRefactoring Functional Type Classes
Refactoring Functional Type Classes
 
One Monad to Rule Them All
One Monad to Rule Them AllOne Monad to Rule Them All
One Monad to Rule Them All
 
Error Management: Future vs ZIO
Error Management: Future vs ZIOError Management: Future vs ZIO
Error Management: Future vs ZIO
 
Atomically { Delete Your Actors }
Atomically { Delete Your Actors }Atomically { Delete Your Actors }
Atomically { Delete Your Actors }
 
The Death of Final Tagless
The Death of Final TaglessThe Death of Final Tagless
The Death of Final Tagless
 
Scalaz Stream: Rebirth
Scalaz Stream: RebirthScalaz Stream: Rebirth
Scalaz Stream: Rebirth
 
Scalaz Stream: Rebirth
Scalaz Stream: RebirthScalaz Stream: Rebirth
Scalaz Stream: Rebirth
 
ZIO Schedule: Conquering Flakiness & Recurrence with Pure Functional Programming
ZIO Schedule: Conquering Flakiness & Recurrence with Pure Functional ProgrammingZIO Schedule: Conquering Flakiness & Recurrence with Pure Functional Programming
ZIO Schedule: Conquering Flakiness & Recurrence with Pure Functional Programming
 
ZIO Queue
ZIO QueueZIO Queue
ZIO Queue
 
Blazing Fast, Pure Effects without Monads — LambdaConf 2018
Blazing Fast, Pure Effects without Monads — LambdaConf 2018Blazing Fast, Pure Effects without Monads — LambdaConf 2018
Blazing Fast, Pure Effects without Monads — LambdaConf 2018
 
Scalaz 8: A Whole New Game
Scalaz 8: A Whole New GameScalaz 8: A Whole New Game
Scalaz 8: A Whole New Game
 
Scalaz 8 vs Akka Actors
Scalaz 8 vs Akka ActorsScalaz 8 vs Akka Actors
Scalaz 8 vs Akka Actors
 
Orthogonal Functional Architecture
Orthogonal Functional ArchitectureOrthogonal Functional Architecture
Orthogonal Functional Architecture
 
The Design of the Scalaz 8 Effect System
The Design of the Scalaz 8 Effect SystemThe Design of the Scalaz 8 Effect System
The Design of the Scalaz 8 Effect System
 
Quark: A Purely-Functional Scala DSL for Data Processing & Analytics
Quark: A Purely-Functional Scala DSL for Data Processing & AnalyticsQuark: A Purely-Functional Scala DSL for Data Processing & Analytics
Quark: A Purely-Functional Scala DSL for Data Processing & Analytics
 
Post-Free: Life After Free Monads
Post-Free: Life After Free MonadsPost-Free: Life After Free Monads
Post-Free: Life After Free Monads
 
Streams for (Co)Free!
Streams for (Co)Free!Streams for (Co)Free!
Streams for (Co)Free!
 
MTL Versus Free
MTL Versus FreeMTL Versus Free
MTL Versus Free
 
The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...
The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...
The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...
 
Halogen: Past, Present, and Future
Halogen: Past, Present, and FutureHalogen: Past, Present, and Future
Halogen: Past, Present, and Future
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Getting Started with PureScript

  • 2. Agenda • Introduction • What is PureScript • Syntax & Semantics • Who Uses PureScript • Why PureScript • Ecosystem • Getting Started • Node.js • NPM • Bower • PureScript • Pulp • Hello World
  • 3. What is PureScript? PureScript is a strongly-typed, purely-functional programming language that compiles to Javascript1 , and is written in and inspired by Haskell. 1 And C++!
  • 4. Syntax import Control.Apply import Graphics.Canvas.Free scene = filled $ closed do moveTo 0 0 lineTo 50 0 lineTo 25 50 where closed path = beginPath *> path <* closePath filled shape = shape <* fill
  • 5. Semantics • Type Inference • Higher-Kinded Polymorphism • Support for basic Javascript types • Extensible records • Extensible effects • Optimizer rules for generation of efficient Javascript • Pattern matching • Simple FFI • Modules • Rank N Types • Do Notation • Tail-call elimination • Type Classes
  • 6. Who Uses PureScript?2 • SlamData • Xamarin • DICOM Grid • Middlebury Interactive Languages • DICE.fm • McGraw Hill Financial 2 Cobbled together from various online sources.*
  • 7. Why PureScript? Motivation • You want to or are forced to do front-end or node.js • You like static typing • You like functional programming, of the pure variety • You prefer expressive power over no-frills, opinionated simplicity • You want to crush Javascript/CoffeeScript/TypeScript/Scala3 beneath your heel... BWAHAHA! 3 OK, not quite yet.
  • 8. Why PureScript? ..instead of GHCJS? • "Haskell in hindsight" • Strict versus lazy • Zero runtime • Clean, easy FFI • Great re-use of third-party JS • Simpler language than GHC's quadrillion dialects of Haskell
  • 10. Ecosystem UI Libraries • purescript-halogen • purescript-react • purescript-angular • purescript-rx • purescript-flare • purescript-pux • purescript-optic-ui • purescript-behaviors • purescript-signal • purescript-thermite • purescript-frp-rabbit • purescript-sigment • purescript-ufi And even more!
  • 11. Ecosystem Testing Libraries • purescript-test-unit • purescript-quickcheck • purescript-quickcheck-laws • purescript-strongcheck • purescript-benchotron • purescript-spec • purescript-assert
  • 12. Ecosystem Preludes4 • purescript-prelude • purescript-preface • purescript-batteries 4 Yes, there are multiple!
  • 13. Ecosystem Build Tooling • pulp • grunt-purescript • gulp-purescript • purescript-psa
  • 14. Ecosystem Editor / IDE Support • Atom • purescript-contrib/atom-language-purescript • nwolverson/atom-ide-purescript • Emacs • dysinger/purescript-mode • emacs-pe/purescript-mode • ardumont/psci-mode • spion/purscheck • emacs-pe/flycheck-purescript • epost/psc-ide-emacs • Sublime Text 2 - PureScript package • Vim • purescript-vim • FrigoEU/psc-ide-vim • IntelliJ IDEA - ikarienator/pure-idea • Visual Studio - nwolverson/vscode-ide-purescript • General • kRITZCREEK/psc-ide • To generate TAGS files, use psc-docs --format etags (or --format ctags)
  • 16. Getting Started Prerequisites 1. Node.js 2. NPM 3. Bower 4. PureScript 5. Pulp
  • 17. Getting Started Prerequisites: Node.js Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js' package ecosystem, npm, is the largest ecosystem of open source libraries in the world. Node.js allows full-featured, browser-less Javascript programs.
  • 18. Getting Started Prerequisites: Node.js • Many Javascript dev tools are written in Javascript and run on Node.js • PureScript dev tools are written in PureScript, compiled to JavaScript • Bottom Line: You can't live without it (even if you want to!).
  • 19. Getting Started Prerequisites: Node.js • Installers https://nodejs.org/en/download/ • Homebrew brew install node • MacPorts port install nodejs • pkgsrc pkgin -y install nodejs • Debian / Ubunutu (4.x) curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - sudo apt-get install -y nodejs • Debian / Ubuntu (6.x) curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - sudo apt-get install -y nodejs
  • 20. Getting Started Prerequisites: NPM • NPM = Node Package Manager • Used by Node to manage packages • Many tools and libraries are distributed through NPM • Bottom Line: Another thing you can't live without...
  • 21. Getting Started Prerequisites: NPM • NPM comes pre-installed with Node.js but version may be old • Self-Updating NPM: sudo npm install npm -g
  • 22. Getting Started Prerequisites: Bower • A package manager for the web • Maintains global registry of name -> URL • Supports repositories & tags • Supports all types of dependencies (binary, PureScript, etc.) • Dependencies specified in bower.json file • Bottom Line: Almost all PureScript libraries are registered with bower, and almost all PureScript projects maintain dependencies with bower!
  • 23. Getting Started Prerequisites: Bower { "name": "purescript-library", "description": "A PureScript library", "authors": [ "John A. De Goes <john@degoes.net>" ], "license": "Apache 2", "version": "0.1.0", "ignore": [ "**/.*", "node_modules", "bower_components", "output" ], "dependencies": { "purescript-profunctor-lenses": "^1.0.0-rc.1", "purescript-free": "^1.0.0-rc.1", "purescript-console": "^v1.0.0-rc.1", "purescript-either": "^v1.0.0-rc.1", "purescript-maybe": "^1.0.0-rc.1", "purescript-foldable-traversable": "^1.0.0-rc.1", "purescript-monoid": "^1.0.0-rc.2", "purescript-bifunctors": "^1.0.0-rc.1", "purescript-invariant": "^1.0.0-rc.1", "purescript-prelude": "^1.0.0-rc.4", "purescript-control": "^1.0.0-rc.1", "purescript-transformers": "^1.0.0-rc.1" } }
  • 24. Getting Started Prerequisites: Bower • Install with NPM npm install -g bower
  • 25. Getting Started Prerequisites: PureScript Compiler • psc — PureScript compiler • psc-docs — PureScript documentation generator • psc-bundle — Bundler & dead-code eliminator • psci — PureScript Read-Eval-Print-Loop (REPL) • psc-ide-server — IDE Server • psc-ide-client — IDE Client
  • 26. Getting Started Prerequisites: PureScript Compiler • Installers https://github.com/purescript/purescript/releases/latest • Install with NPM npm install -g purescript
  • 27. Getting Started Prerequisites: Pulp • Pulp: Popular build tool for PureScript projects • Knows how to perform magical incantations of psc & related tools • Bottom Line: If you can use it to build your project, then do it!
  • 28. Getting Started Prerequisites: Pulp • Install with NPM npm install -g pulp
  • 29. Getting Started Hello World 1. Create Directory Structure 2. Create Bower File 3. Install Bower Dependencies 4. Write PureScript Main 5. Build & Run
  • 30. Getting Started Hello World: Create Directory Structure bower.json /src/ /Main.purs
  • 31. Getting Started Hello World: Create Bower File { "name": "hello world", "dependencies": { "purescript-console": "^0.1.1", "purescript-eff": "^0.1.2", "purescript-prelude": "^0.1.5" } }
  • 32. Getting Started Hello World: Install Bower Dependencies bower install
  • 33. Getting Started Hello World: Write PureScript Main module Main where import Prelude(Unit) import Control.Monad.Eff (Eff) import Control.Monad.Eff.Console (CONSOLE, log) main :: forall e. Eff (console :: CONSOLE | e) Unit main = do log "Hello World!"
  • 34. Getting Started Hello World: Build & Run pulp build pulp run
  • 35. Congratulations, You've Started Your Journey Into The World of PureScript! Don't Forget the Easy Peasy PureScript Workshop at LambdaConf 2016! More Resources: http://purescript.org