Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Serverless Haskell

Serverless Haskell

Slides from a talk on Serverless Haskell at the Melbourne Haskell Users Group meetup, 22nd February 2018

David Overton

February 22, 2018
Tweet

More Decks by David Overton

Other Decks in Programming

Transcript

  1. Serverless Haskell
    Alexey Kotlyarov & David Overton

    View full-size slide

  2. 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

    View full-size slide

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

    View full-size slide

  4. 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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  7. Alternative events
    ● Compose handlers for different types of events

    View full-size slide

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

    View full-size slide

  9. 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

    View full-size slide