Electric Froth

______ _ ______ ( / // _/_ o ( / _/_ / /-- // _ _, / _ , _, -/--_ __ / /_ (/____/(/_(/_(__(__/ (_(_(__ _/ / (_(_)(__/ /_



by Joel Kleier on 2014-10-25

I've always had a fondness for programming languages, and one that caught my eye recently is PureScript -- a strongly and statically typed language in the vein of Haskell (which I've never really learned proper, though I have it on the 'maybe someday' list). PureScript, though, compiles to JavaScript -- which, despite it's warts, is a language that I think is the bees knees.

There's a book out there for it, available free to read online, so I thought I'd just start going through it to check out the language.

It has you install The Haskell Platform (for the actual compiler), node/npm (for node based utilities and tools), Bower (for all the PureScript packages), and then Grunt (to automate builds and such).

Well, that's a pretty big stack to install just to write some "Hello World" equivalent programs... but, I don't mind! Already had most of them installed anyway. However, their setup is not how I prefer to work (when I'm working on my own projects at least).

Here are my deviations from the books setup:

  1. I installed Bower locally to the folder (I don't like polluting my global npm packages if I don't have to... and prefixing ./node_packages/.bin/bower doesn't bother me since I'm scripting my builds anyway).
  2. I Started using GNU Make instead of Grunt. Why? Sure, grunt is the new 'hot' thing, but, for my purposes, it's clearly a reinvention of a wheel that works really well. I like GNU Make, and it will serve me better than Grunt (that's not to say Grunt is useless, but in this instance I prefer to stick with the tried and true).

So, my Makefile looks something like this:

BOWER_FILES=`find ./bower_components -regex ".*/src/.*\.purs"`
          ${CHAPTER2_FILES} \

all: Chapter2 PhoneBook

    npm install bower
    bower install purescript-math#0.1.0
    bower install purescript-list

    psci ${ALL_FILES}

    psc ${BOWER_FILES} \
        ${CHAPTER2_FILES} \
        --output dist/Chapter2-Main.js \
        --module Chapter2 \
        --main Chapter2

Some explanations:

Hopefully I get some time soon to play with PureScript some more! So far my impressions are very positive!