Skip to content

Instantly share code, notes, and snippets.

@maciejsmolinski
Last active June 6, 2018 08:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maciejsmolinski/49577db37273861c864c5ec5df51ae14 to your computer and use it in GitHub Desktop.
Save maciejsmolinski/49577db37273861c864c5ec5df51ae14 to your computer and use it in GitHub Desktop.
Create ES6 + PureScript application in 4 simple steps

In the project directory:

  1. Install global dependencies https://streamable.com/era9s
    • yarn global add purescript@0.11.7 psc-package pulp
  2. Generate an example project in the current directory https://streamable.com/gcjih
    • pulp --psc-package init
  3. Install web application bundler https://streamable.com/f9l56
    • yarn add parcel
  4. Call purescript from JavaScript https://streamable.com/u5s49
    • yarn dev and pulp --watch build

package.json

{
  "dependencies": {
    "parcel": "^1.8.1"
  },
  "scripts": {
    "dev": "parcel serve src/index.html"
  }
}

src/index.html

<html>

<head>
    <title>PureScript Application</title>
</head>

<body>
    <script src="./index.js"></script>
</body>

</html>

src/index.js

const Main = require('../output/Main/index');

console.log('Hello from JavaScript');

Main.main();

src/Main.purs

module Main where

import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log)

main :: forall e. Eff (console :: CONSOLE | e) Unit
main = do
  log "Hello from PureScript!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment