Note: This repository is a point-in-time demonstration, reflecting what was current as of June 2026. It is not actively maintained, and
hal/wai-handler-halis no longer considered the obvious default for putting Haskell on Lambda. A rough rule of thumb:
- If your Lambda is obviously a Lambda — a side-effectful function that consumes and returns JSON, invoked as an event handler rather than as an HTTP service —
hal(optionally withwai-handler-halif you also want to expose it behind API Gateway) is still a reasonable, direct fit.- If your Lambda is really a web service that happens to run on Lambda, prefer building an ordinary Haskell server binary (e.g.
warp) and deploying it with the AWS Lambda Web Adapter, either as a container image or as a Lambda Layer. This is cheaper to run behind an HTTP API Gateway, and also opens up Lambda Function URLs and Application Load Balancers as integrations —halhas no JSON mappings for those event/response formats, only for the API Gateway REST API proxy integration shown in this example.
This package shows how to run a Servant API on AWS Lambda. Servant
returns a WAI Application, which we wrap with wai-handler-hal and
run with hal's 'mRuntime. This allows us to deploy the binary to
AWS Lambda, and use it as a Lambda Proxy
Integration
of an AWS API Gateway REST API (only).
A second executable runs the same WAI Application on the
warp web server. This is
great for local testing.
Two endpoints are provided:
GET https://abcde12345.execute-api.us-east-1.amazonaws.com/prod/hoot--- returns{ "message": "hoot" }GET https://abcde12345.execute-api.us-east-1.amazonaws.com/prod/greet?person=Roy--- returns{ "message": "Hello, Roy!" }
Follow the instructions in the wai-handler-hal-cdk subdirectory to
build the deployment package and deploy it to AWS using AWS CDK
v2.
There is a development shell provided. Users on x86_64-linux can run
nix develop, and then run npm install from within the
wai-handler-hal-cdk subdirectory.
Some people might prefer to deploy OCI Container Images to Elastic Container Registry. There are additional flake outputs showing how to package Lambda binaries into container images:
packages.x86_64-linux.containeris a standard container image built atop Amazon's base image.packages.x86_64-linux.tiny-contineris a minimal container image consisting of busybox, Amazon's AWS Lambda Runtime Interface Emulator, and the bootstrap binary.