PureScript is a delightful pure functional language that offers pragmatic and powerful tools to help you design, build, and refactor reliable apps of any size. This repository demonstrates the principles I apply at work every day in more than 2,000 lines of thoroughly commented code.
I’m a developer at Awake Security (and previously at CitizenNet). Both companies have large production PureScript applications that have remained reliable, understandable, and maintainable as they scale.
This repository follows the RealWorld spec to implement a Medium clone called Conduit using Halogen. It’s large enough to demonstrate real world examples (CRUD, state management, scalable architecture, type classes, components, etc.) but not so large as to be overwhelming. There is also a Real World PureScript React project that demonstrates the same project using React bindings from PureScript.
The source code currently covers Halogen 7 with PureScript 0.15, but there are versions for versions going back to Halogen 4:
If you have found this repository and the guide useful, please consider becoming a sponsor!
First, clone the repository:
$ git clone https://github.com/thomashoneyman/purescript-halogen-realworld
Cloning into 'purescript-halogen-realworld'...
...
Resolving deltas: 100% (...), done.
$ cd purescript-halogen-realworld
You can enter a development shell with all non-JavaScript dependencies via Nix:
$ nix develop
Alternately, you can install purescript
, spago
, purs-tidy
, purescript-psa
, and the PureScript language server from NPM.
Next, install JavaScript dependencies:
$ npm install
Next, build the project (this command will run spago build
; see the package.json
file to see
all helper scripts for the project):
$ npm run build
You can bundle the JS for production:
$ npm run bundle
You can run a dev server to use Conduit:
$ npm run serve
...
> Local: http://127.0.0.1:8000/
> Network: http://192.168.1.67:8000/
When you reload the application in the browser, esbuild
will re-bundle the application using the latest compiled PureScript in the output
directory. If you're using the PureScript language server, then this directory will be updated when you save files via incremental compilation.
This project is intended to give non-PureScript developers a taste of what a small application in the language looks like, and to give advanced beginners in PureScript a resource to feel comfortable building reliable applications of their own.
PureScript is a delightful language that becomes only more interesting and rewarding the more you use it and the larger your application becomes; if you haven’t yet tried it out, I encourage you to do so. Not convinced? Kris Jenkins has a lovely talk about PureScript which might change your mind.
The PureScript community is warm and helpful. If you would like some help getting started, please consider joining the official Discourse and official chat. You may also want to check out:
PRs are welcome! Any functional changes will need to remain compliant with the RealWorld spec, and I may re-word documentation changes to fit with the voice used throughout the repository.