futurice/haskell-aws-lambda-kleisli

Name: haskell-aws-lambda-kleisli

Owner: Futurice

Description: Run Haskell on AWS Lambda

Created: 2018-04-23 10:55:00.0

Updated: 2018-04-29 06:57:33.0

Pushed: 2018-04-27 09:36:26.0

Homepage: null

Size: 191

Language: Haskell

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Kleisli: Haskell on AWS Lambda

AWS Lambda functions aren't pure ones.

Synopsis

On Linux


will create an uploadable Kleisli.zip with a simple AWS lambda function.

Screenshot

This is a “boilerplate” to lift handler :: (String -> IO ()) -> Value -> IO Value into AWS Lambda execution context! (first argument is a logging function).

How it works

There three layers:

Makefile ties all that together.

Notes
Why?
Why not child process?

Going through Python and using shared object seems to be much cleaner approach than spawning a child process.

Assumptions

Some paths are hardcoded, grep for 2.7 and 8.2.2.

Package size

The resulting Zip file is 14M large (50M is the maximum package size, see Limits), it's using lens.

Logging

AWS Lambda environment seems to hook print somehow to enable logging. Printing to stdout (e.g. print, putStrLn etc.) doesn't put anything into logs. Therefore there is a small “workaround”: we pass Python's print as an argument to Haskell's handler.

ctypes

Using ctypes to load Haskell dynamic library could also work. Not sure how to make logging work then though. See e.g. Building AWS Lambda function in Rust for an example.

Related work
Links

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.