Here you may find TODO-list full-stack application implemented generated with IHP, web framework for Haskell.
It has basic CRUD operations, renders HTML as a response, uses built-in Postgres server as a storage, and additionally implements a simple custom logger middleware.
The main goal of this project is to provide a basic example of implementing web app with IHP framework. In particular, to show how (mostly generated) code looks, and to demonstrate how custom middleware could be added. So to make life a bit easier for (future) Haskell web developers. It's already pretty easy with IHP, though 😉
This code complements the talk "How to Choose a Haskell Web Framework" I presented at Haskell eXchange 2022.
In this talk, I show how some of Haskell web tools approach web development. In particular, there are 3 of them — Servant, Yesod and IHP.
There are also corresponding Servant and Yesod TODO-list implementations.
Check out the presentation slides and the talk recording, and contact me if you have any questions 🙂
As application is intended to have just basic CRUD operations, only generated API is used, and here it is
GET /Tasks
— get all tasksPOST /NewTask
— create new taskGET /ShowTask?taskId={id}
— get existing task byid
PUT /EditTask?taskId={id}
— update existing task byid
DELETE /DeleteTask?taskId={id}
— delete existing task byid
Here is how task creation, deletion and update may look like.
Simple logger here just extracts request’s URL path and logs it with "Info" verbosity level.
For example,
[Info] url-path=Tasks
[Info] url-path=ShowTask
[Info] url-path=Tasks
[Info] url-path=NewTask
[Info] url-path=Tasks
[Info] url-path=DeleteTask
To run the app, simply start the development server
> ./start
IHP> Server started
...
Hope you'll find it helpful 💙