In the project directory:
- Install global dependencies https://streamable.com/era9s
yarn global add purescript@0.11.7 psc-package pulp
- Generate an example project in the current directory https://streamable.com/gcjih
pulp --psc-package init
- Install web application bundler https://streamable.com/f9l56
yarn add parcel
- Call purescript from JavaScript https://streamable.com/u5s49
yarn dev
andpulp --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!"