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:
- Web server with Snap: http://snapframework.com/,
- Postgresql db interface with postgresql-simple: http://hackage.haskell.org/package/postgresql-simple,
- Testing/Deployment with Docker.
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.
- PostgreSQL Basics:
- tutorialspoint: postgresql: http://www.tutorialspoint.com/postgresql/index.htm
- official documentation: http://www.postgresql.org/docs/9.4/static/
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
- No haskell stack: https://github.com/commercialhaskell/stack
- cabal sandbox
- Emacs with haskell-mode and ghc-mod
I used docker-compose to setup below stack at once:
- snap application
- nginx web server
Here are dependent docker images:
- haskell: https://hub.docker.com//haskell/
- nginx: https://hub.docker.com//nginx/
- postgres: https://hub.docker.com//postgres/
- Adminer was my buddy helping me to try and debug postgresql queries.
- Nginx server_name directive:
- Try other feature of snap:
- Snaplet module: http://snapframework.com/docs/tutorials/snaplets-tutorial
- Try other framework:
- Try solider persistence management:
- persistent: https://www.stackage.org/package/persistent
- Try solider migration management:
- Create frontend app, SPA by Elm: http://elm-lang.org/