- node / npm installation
- install bower using npm
- purescript tools available on your
$PATH
- (fine to just unload the
tar.gz
into/usr/local/bin
or whatever ornpm -g install purescript
andpulp
)
$ mkdir foo; cd foo; pulp init
pulp run
- should see the familiar
$ Hello sailor!
- see footer for other ways of running this program outside of a browser, or...move on to making it a webapp
$ mkdir dist; cd dist
- make a minimal
index.html
in thisdist
directory
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<script src="app.js" charset="utf-8"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
PS.Main.main();
});
</script>
</body>
</html>
- back up in top level dir we use
psc-bundle
to make browser-ready bundle $ psc-bundle output/**/*.js -m Main > dist/app.js
- note that we use
-m Main
to identify a module that we want to include - but we don't give
psc-bundle
a--main Main
option: we don't want the mainline called automatically
- it's enough to do
$ cd dist; python -m SimpleHTTPServer
- load page as
http://localhost:8000
- you should see the "Hello, sailor!" on the JS console
- you should be able to do
> PS.Main.main()
to call this mainline - note that currying means you need to call multiparam functions explicitly (
> PS.Main.otherfunc(p1)(p2)
)
- you can run this tiny program in a Purescript REPL by doing
$ pulp psci
. You have to import - at a minimum - theMain
module which you can simply do as> import Main
which allows you to then do> main
and see your "Hello, sailor!" logged out. - <TBA - how to run this from within a node REPL or script>
https://www.agileand.me/express-js-keeping-sane-with-purescript/