Slide 1

Slide 1 text

Serverless Haskell Alexey Kotlyarov & David Overton

Slide 2

Slide 2 text

Motivation ● AWS Lambda and the Serverless Framework make it easy to write small functions and deploy them to the cloud… ● … but not in Haskell ● Aim: to make it as easy to do serverless programming in Haskell as it is in NodeJS or Python ●

Slide 3

Slide 3 text

What we did ● Serverless Haskell ● Developed over a 3 day Hackathon at SEEK in December 2017 ● Consists of ○ A Serverless plugin ○ A Haskell library

Slide 4

Slide 4 text

Serverless plugin ● Provides a NodeJS wrapper that spawns your Haskell executable ● Hooks up pipes for input, output and logging ● At the moment it will spawn a new exe on each invocation ● Future plan: keep the exe running so that it can handle multiple invocations

Slide 5

Slide 5 text

Haskell library lambdaMain :: (Aeson.FromJSON event, Aeson.ToJSON res) => (event -> IO res) -- ^ Function to process the event -> IO ()

Slide 6

Slide 6 text

Event types Types for dealing with common Lambda events So far ● SNS ● S3 ● Kinesis ● APIGateway Plan to add more.

Slide 7

Slide 7 text

Alternative events ● Compose handlers for different types of events

Slide 8

Slide 8 text

Embedded events ● Some event types (e.g. SNS, APIGateway) have stringified JSON or Base64 embedded within string values in the JSON ● TextValue and Embedded

Slide 9

Slide 9 text

Examples

Slide 10

Slide 10 text

Conclusion ● We have several Lambdas at SEEK using this ● GitHub https://github.com/seek-oss/serverless-haskell ● Also on npm, hackage and stackage ● Future extensions: ○ Allow more than one Lambda invocation ○ Allow multiple functions per project ○ Expand the supported event types ● We would love to get more users ● Pull requests invited