70 %
Chris Biscardi

Getting Started With Snap (and User Authentication): Part 1

Part 2

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:

bash
hsenv --ghc=7.6.3

or download the package for ghc-7.6.3 here and run this:

bash
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.

bash
mkdir abc
cd abc

It’s good to update the package list when starting a new project:

bash
cabal update
cabal install cabal-install

After updating and installing the new version of cabal-instal we can install snap:

bash
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

bash
snap init
cabal install
abc -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.

Part 2 – Auth

Part 3 – Postgres Backed Auth