Before we get started, there is a quickstart on the
snap-framework site
here that goes
into the barebones
scaffold project a bit. This course
will go a little more in depth into the default
project,
exploring user authentication.
I use hsenv to create separate Haskell environments, but that is not a requirement and beginners may be more comfortable installing the Haskell Platform
If you wish to use hsenv, you can run this on newer versions:
hsenv --ghc=7.6.3
or download the package for ghc-7.6.3 here and run this:
hsenv --ghc=/path/to/downloaded/ghc-7.6.3-x86_64-apple-darwin.tar.bz2
From here on out the process is the same if you’re using hsenv or not. Create a new directory named “abc” and enter it. This will also function as the name of our project and executable.
mkdir abccd abc
It’s good to update the package list when starting a new project:
cabal updatecabal install cabal-install
After updating and installing the new version of cabal-instal we can install snap:
cabal install snap
At this point we will have the snap
CLI and can run init
to scaffold a default project. After scaffolding, we then
run cabal install
to compile the binary and abc
to run
the project. abc
will also take a port as such:
abc -p 8000
snap initcabal installabc -p 8000
Our app, abc, should now be running. Navigate to
localhost:8000
(or the port you specified) in your browser
to take a look.
In the next post we’ll take a look at the code we generated and take a brief overview of what it does.