In this project an API rest with servant, postgresql-simple was created. Using Type-Classes and Tagless Final.
- Haskell Stack.
- Cabal.
- Docker.
- Docker Compose.
- libpq.
$ brew install libpq # or brew install postgresql
$ brew link --force libpq # export PATH="/usr/local/opt/libpq/bin:$PATH"
$ sudo apt-get install libpq-dev # or sudo apt-get install postgresql postgresql-contrib
$ sudo pacman install postgresql-libs
$ docker-compose up -d
$ stack build
$ stack exec haskell-http-exe
$ curl --location --request GET 'http://localhost:8080/products'
$ curl --location --request GET 'http://localhost:8080/products/{UUID}'
$ curl --location --request POST 'http://localhost:8080/products' \
--header 'Content-Type: application/json' \
--data-raw '{
"product_name": "New Product Name",
"product_stock": 22.0
}'
$ stack install ormolu --resolver=lts-16.11
$ ormolu --mode inplace $(find . -name '*.hs')
$ cabal update
$ cabal new-install ormolu
$ ormolu --mode inplace $(find . -name '*.hs')
$ stack test # or `stack ghci haskell-http:haskell-http-test`