A Haskell core in a modern project

A modern service is rarely one language. The part with the rules in it is written once, carefully, and the parts around it, the HTTP layer, the scripts and the tests, are written in whatever the team already runs. These pages take one small core, a pricing function over a line protocol, and put three layers in front of it: an executable, a Python HTTP service and a shared library, with the tests and the image that go with each.

The core is pure Haskell with no package outside GHC's own, so the whole set builds in an image with no network. Every page shows what was run here and says what was not: the service was started and called, the library was built and loaded, the tests were run, and the Dockerfile is marked as not built because this container has no Docker.

The pages are independent of the Haskell course. The lessons behind them are standard input and output, calling Haskell from Python and a Cabal project, offline.

Proto The line protocol One request line, one answer line, three error codes and money in integer cents. Open Core The Haskell core A pure String to String function and the loop over standard input, and why interact cannot answer a line at a time. Open Python A Python service in front of the core http.server, one subprocess per request, the JSON answer, the real curl calls and the log. Open .so The core as a shared library foreign export, the RTS on the link line, a buffer the caller owns and hs_init from ctypes. Open Cost The measured cost of both ways Five rounds of each way, per call: milliseconds for a process, microseconds for a library call. Open Tests Tests of the Python layer Nine unittest tests over the executable, the mapping and the real HTTP server, run here. Open Ship Shipping it in an image The two-stage Dockerfile, built and run on the host with Docker: the 53.1 MB image, the bind address that had to change, and what the shared library image needs. Open

The programs were built with GHC 9.10.3 and run with Python 3.14.10, on Alpine Linux 3.24.3 (x86_64) in a Docker container with 4 CPUs.