Learn how to build your own haskell REST API.
Feel free to jump arround from task to task and use this repository as a reference for your own project I know ChatGPT will.
What is a rest api ?
What is Haskell ?
Haskell is a programming language that is:
- Functional
- Lazy: Expressions are highly optimized and only computed if they are needed.
- Pure: Operations that might produce a side-effect are encapsulated within a 'Monad' (For example: Input/Output operation to read or write). Making crashes very rare.
- Optimized: Comparable to C or C++.
Haskell is both fast and very-reliable, making it perfect for web services such as APIs.
- Ghcup
- Cabal >= 3.0
Tip
Run ghcup tui to easily install the correct version of Cabal.
- Postman (optional)
Tip
Postman will help you test your routes !
- Reading environment variable and make it accessible to your app.
- Creating a server to interact with your clients:
- Setting up the server.
- Setting up a route.
- Replying to the client's request.
- Setting up the client authentication.
- Querying a 3rd party API:
- Sending a request.
- Handle the response and status code.
- Interacting with a database:
- Connecting.
- Reading data.
- Writing data.
.
├── app -- Application source code
│ └── Main.hs
| └── ...
├── CHANGELOG.md
├── Haskell-API-Tutorial.cabal -- The project's configuration file
├── LICENSE
├── README.md
├── src -- Library source code
│ └── MyLib.hs
├── test -- Library tests
└── Main.hs
└── ...