A strongly-typed …
The types of values are not implicitly converted by the compiler. This enables one to write fewer incorrect programs. Although not stated in the definition, another tangentially related feature of PureScript is that it is statically typed. In short, this means that your program is checked for correctness enforced by type specification at compile-time, avoiding a slew of errors at run-time.
… functional programming language …
The functional programming (FP) paradigm enforces several constraints and manners of program composition that enable the programmer to write less incorrect code. Essential to this is the explicit separation of ‘pure’ code from that with side effects, sometimes referred to as ‘IO.’ Further, information carried through the program is immutable. This has the benefits of avoiding erroneous ‘altering’ of information, in addition to leading the programmer to consider the computational ‘cost’ of manipulating the information. There are many who can better wax eloquent on the nuances and benefits of the FP paradigm, so I will leave it at that.
In sum, I see benefit in being able to write more-correct code that does something useful and practical. By working with PureScript I hope to deepen my understanding of FP, along with widening my skill-set to command of web applications. On a more personal level, I have fun creating programs, and find satisfaction in doing that well.
Choosing where to begin
A brief search led me to an article2 outlining several of the build tools and package managers available. Spacchetti seemed the most appealing, mainly because it would be an opportunity to try out using Dhall3. Upon pursuit of Spacchetti, I learned that it is effectively deprecated, and that using spago4 would be the more appropriate option.
Getting spago going
I opted for compiling spago from source5.
$ git clone https://github.com/spacchetti/spago.git ... $ stack install ...
On my machine6, the
stack install command took about three minutes to complete. Upon completion, I was greeted with one warning7, which I hope to be effectively benign, and two executables installed in my
Installing the PureScript compiler
At the time of this writing, the latest version of the PureScript compiler available on Homebrew is 0.12.5; spago loosely requires8 the most up-to-date version of the compiler, which is 0.13.0. Thus, I will install from source9 in lieu of Homebrew.
$ stack unpack purescript ... $ cd purescript-0.13.0 $ stack install --flag purescript:RELEASE ...
It takes my machine about 18 minutes and lots of fan-spinning to progress through the installation. I am now rewarded with the
purs executable installed in my
Testing the environment
Following the “Super quick tutorial”10 for spago, I can now see that my environment will successfully build.
$ spago build ... Build succeeded.
Next I try to use
node to see the project running, given that it was just successfully built. I already have
node installed via Homebrew, so I input the following command readily.
$ node -e "require('.output/Main/index').main()"
I received an error in response11. In life, I choose to be an optimist, and that is why I hoped and believed that upgrading my
node installation would solve my problem.
$ brew upgrade node ... node -e "require('./output/Main/index').main()" 🍝
Success! Never have I been so pleased to see the spaghetti emoji.
PureScript home page↩
A quick overview of PureScript package managers as of October 2018↩
dhall-lang on Github↩
spago on Github↩
spago on Github - installation↩
Hardware: 2013 MacBook Air, 1.7 GHz Intel Core i7, 8 GB memory. Software:
A warning from stack after installing spago from source:
warning: non-portable path to file '".stack-work/dist/x86_64-osx/Cabal-188.8.131.52/build/Spago/autogen/ cabal_macros.h"'; specified path differs in case from file name on disk [-Wnonportable-include-path] #include ".stack-work/dist/x86_64-osx/Cabal-184.108.40.206/build/spago/ autogen/cabal_macros.h"
The error message after calling
spago buildwith the Homebrew version of the PureScript compiler:
spago: Oh noes! It looks like the PureScript version installed on your system is not compatible with the package-set you're using. installed `purs` version: 0.12.5 minimum package-set version: 0.13.0 ... - if you know what you're doing and you want to void this check, you can override the `version` of the `metadata` package in the packages.dhall
PureScript - Compiling from source↩
spago - Super quick tutorial↩
The error message when trying to use the
nodecommand in the terminal:
dyld: Library not loaded: /usr/local/opt/icu4c/lib/ libicui18n.62.dylib Referenced from: /usr/local/bin/node Reason: image not found Abort trap: 6