PureScript

Gregor Riegler

Lambdaheads Vienna -- May 13, 2015

PureScript

  • Compiles to JavaScript
    • to use in your browser
    • to use on Node.js

 ⇒  write Web Applications!

PureScript

  • Statically typed and similar to Haskell

  • Another language to target JavaScript as
    • TypeScript
    • Dart
    • CoffeeScript
    • ... and others

PureScript Motivation

Solutions at the time included various attempts to compile Haskell to JavaScript while preserving its semantics (Fay, Haste, GHCJS), but I was interested to see how successful I could be by approaching the problem from the other side - attempting to keep the semantics of JavaScript, while enjoying the syntax and type system of a language like Haskell. -- Phil Freeman

PureScript ?= Haskell

In the case of purescript, it really does seem to be turning into a gateway drug to get folks into the Haskell community, much the way Scala used to be (and still is to a lesser extent), but closer in spirit.

edwardkmett, 04/30/2015

PureScript /= Haskell

  • Strict evaluation  →  no "lazyness"
  • Fine-grained "IO" monad called the "Eff" monad
  • Literal syntax for arrays instead of lists
  • "Row types" - Records similar to JavaScript records
  • Foreign Function Interface for JavaScript interoperation
  • ... and some others in the wiki

Try PureScript

TryPureScript.org

Install tools

  • psc - PureScript compiler
    • cabal install purescript
  • npm - Node Package Manager
  • grunt
    • Build Automation Tool
    • npm install -g grunt-cli
  • bower - for PureScript dependencies
    • npm install -g bower

Useful resources

Live Demo

Learn PureScript 1

Best Learning Resource

  • PureScript By Example
    • can be read online, free donations
    • a very thorough and yet exciting read!
    • written by the PureScript creator Phil Freeman

Learn PureScript 2

Other Resources

PureScript rocks?!

Thanks for your attention!
Thanks for your attention!