Web App with Haskell
Created at 2016-05-07T01:05:50.000Z

This post is about my first trial of creating web application with Haskell. Source code is here: hi-ogawa/snap-todo-app.


I read some of references comparing Haskell web frameworks:

For starter, I decided to go with the stack below:

I'm not familiar with Template Haskell kinds of GHC magical extension, so I chose Snap instead of Yesod. The reason why I didn't use persistent is same.

Database

Relevant code: https://github.com/hi-ogawa/snap-todo-app/blob/3afda0329dfd4f6884e726ca6ef290f58b49ce31/src/Todo.hs

It's a shame, but I really had never written raw SQL command by hand since I totally relied on ruby ORM. So, I needed to start with some of basics about database.

Migration

For now, I manage migration by hand with ".sql" files. Since I was using docker for preparing db, the command was like below:

$ psql -U postgres -w -h $(docker-machine ip default) -p 5432 postgres < db/migrations/20160501_create_todo_table.sql

Development

Deployment

I used docker-compose to setup below stack at once:

  • snap application
  • nginx web server
  • postgresql

Here are dependent docker images:

Testing

With similar docker-compose script, I setup continuous integration on jenkins.

Small Tips

Future work