$30 off During Our Annual Pro Sale. View Details »

PureScript Get Started

wuct
August 02, 2018

PureScript Get Started

Setup the environment, install dependencies and use PureScript REPL to learn types!

wuct

August 02, 2018
Tweet

More Decks by wuct

Other Decks in Programming

Transcript

  1. PureScript Get Started CT Wu wu_ct wuct

  2. Some learning resources • PureScript by Example (free e-book) •

    Learn You a Haskell for Great Good (free e-book) • Haskell Book ($59, the best e-book IMO) • egghead.io (free online videos) • purescript-users.ml/ (Discourse) • Functional programming on slack (#purescript, #purescript-beginner) • https://www.facebook.com/groups/PureScript.tw (Facebook group)
  3. Tools • purs - The PureScript compiler itself • pulp

    - A CLI tool which automates many of the tasks • psc-package - A package manager for PureScript • To install them all: • npm i -g purescript pulp psc-package-bin-simple • yarn global add purescript pulp psc-package-bin- simple
  4. Init a project

  5. Install a package

  6. Open REPL

  7. Open REPL

  8. Simple Types

  9. Records

  10. Functions

  11. Type Annotation

  12. Type Signature Notation in PureScript “::” is for type annotations

    "PureScript" !:: String New types can be created via type constructors ["PureScript"] !:: Array String ![["Pure"], ["Script"!]] !:: Array (Array String)
  13. Type Signature Notation in PureScript → is an infix type

    constructor for functions String → Number A function with multiple → is a curried function String → String → String
  14. Type Signature Notation in PureScript ∀ (forall) is the universal

    quantifier and lowercase letters stand for type variables ∀ a. a → a 㱺 expresses constraints on type variables ∀ a. Monoid a ⇒ a !-> a !-> a
  15. Q & A

  16. Learn once, apply everywhere. wu_ct wuct