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++!
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
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!).
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...
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!
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!
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!"
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