https://github.com/stackbuilders/haskell-faas-template
Haskell Faas Template
https://github.com/stackbuilders/haskell-faas-template
Last synced: 19 days ago
JSON representation
Haskell Faas Template
- Host: GitHub
- URL: https://github.com/stackbuilders/haskell-faas-template
- Owner: stackbuilders
- Created: 2021-11-17T16:24:26.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-06T14:48:52.000Z (over 3 years ago)
- Last Synced: 2025-01-23T04:32:43.717Z (about 1 year ago)
- Language: Roff
- Homepage:
- Size: 96.7 KB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Developing in Haskell
Here you will find a Haskell template to start developing functions working with the HTTP protocol.
## Making a Function
In order to interact with HTTP protocol, we need to use the `haskell-http` function template:
```
faas-cli template pull git@github.com:stackbuilders/haskell-faas-template.git
```
This will pull all the templates available in the Stackbuilders repository.
Then, we will create a new haskell function using:
```
faas-cli new --lang haskell-http
```
Replace the `` with a descriptive name for your function.
Now, we will get a description of our project in the `.yml` file. The `` directory contains the necessary resources to implement our "lambda" function. It should look like this:

Inside the `` directory we will find:
- `cabal.project`: Here you can import libraries that are not present in [Hackage](https://hackage.haskell.org/) (i.e. custom libraries)
- `haskell-template-function.cabal`: Here you will import the libraries needed in order to build the function. You can import libraries inside the `build-depends` section like this:

- `src`: In this directory you will find the `Handler.hs`. This is the "main" module for your FaaS function. This is the module responsible for taking the input and outputting the response.
- `test`: Directory with the `HandlerSpec.hs` file. Here you can use the `Hspec` library to write tests for your function.
For this template we use Scotty as our web framework,we choose it because Scotty is a cheap and cheerful way to write RESTful, declarative web applications. When you want to create a page it is as simple as defining the verb, url pattern, and Text content. Besides, it is template-language agnostic. Anything that returns a Text value will do. And, it Uses very fast Warp web server by default.
### Note:
We have used an oficial image from Docker to create a personalized one to harbor the needed precompiled dependencies. It is possible to visualize it at the next repository: [https://github.com/stackbuilders/haskell-faas-template]