tweag/functionless

Name: functionless

Owner: Tweag I/O

Description: CLI tool for packaging Haskell executables for AWS Lambda

Created: 2017-02-01 15:17:25.0

Updated: 2018-05-15 19:44:13.0

Pushed: 2017-06-02 14:49:25.0

Homepage:

Size: 156

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Functionless

Functionless is a tool that allows you to use Haskell functions as lambas on AWS Lambda.

It provides:

How to use it
Your program
Build options

functionless requires a few things from your build options:

c-options: -dynamic -threaded -Wall
-options: -pie
Your lambda

Your lambda handler will have the following type:

Handler :: a -> BS.ByteString -> IO BS.ByteString

The a here is for the Context of AWS Lambda, which is not currently supported by functionless, but will be if users express such a need.

Inputs and outputs are in the form of ByteStrings because we use the stream API of AWS Lambda.
Users will thus have to deserialize their input and serialize their output.

The last part is to use the Functionless.TH.makeAwsLambdaHandler template Haskell function on your handler function like this:

AwsLambdaHandler 'realHandler

This is used to do the proper type conversions from Java, and generate the appropriate JNI bindings for your function to be found.

Package the program

In order to package your program into a usable .jar, simply call functionless on your executable target:

k --nix exec -- functionless your-exe

One of the reasons you needed an executable is for easily finding your binary, this is used by functionless in order to find the package.

The previous command will generate the your-exe.jar, .jar that you can then upload on the AWS console.

Local testing

functionless also provides an easy way to test locally.

If you launch your executable on your machine using:

 -jar your-exe.jar

Your handler, will be called on your machine and will use stdin as its input stream, and stdout as is output stream. This avoids going back and forth to the AWS console to test your program.

Road ahead
User side
Library side

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.