[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Experiments about running Haskell via WebAssembly on Fastly

Notifications You must be signed in to change notification settings

nomeata/haskell-on-fastly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Haskell on Fastly experiments

This repo contains an experiment with compiling Haskell to WebAssembly and runnig it on fastly’s Compute@Cloud service.

See it in action on https://haskell-on-fastly.edgecompute.app/

Moving parts

How to build, test and deploy

  1. Install nix
  2. Enter a nix shell using nix develop. You now have tools like fastly, viceroy and especially wasm32-wasi-ghc available.
  3. Compile using
    wasm32-wasi-ghc --make fastly-sys.c hello.hs
    
  4. Run locally with
    viceroy -v hello.wasm
    
  5. Deploy using fastly compute build && fastly compute deploy, after setting up the fastly instance.

Status

This is just a small demo. It supports

  • Reading method and URI from the request
  • Adding headers and body to the response

There is still much

TODO

  • Cover more of the Fastly API

    Mostly tediuos work, and in the bright future something like the WASM Component model will make that much easier.

  • Be compatible with WAI. This would allow us to compile any WAI-compatible Web application to run on Fastly.

    Should not be hard, but I got stuck with the unix package not compiling on this target yet. So best to wait for the Haskell-on-WebAssembly eco system to mature a bit more.

  • Optimize (mabye disable GC, maybe pre-evaluate the binary using wizer).

Contributions are welcome!

Credits

Thanks to Cheng Shao aKa TerrorJack for his work on GHC-to-WebAssembly and help with these experiments.

About

Experiments about running Haskell via WebAssembly on Fastly

Resources

Stars

Watchers

Forks