servant-wasm: Servant support for delivering WebAssembly

[ bsd3, library, program, web ] [ Propose Tags ]

Facilities to help deliver WASM from a servant-server.

[Skip to Readme]


[Index] [Quick Jump]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS],
Change log
Dependencies base (<5), bytestring, servant, servant-server, servant-wasm, transformers, warp [details]
License BSD-3-Clause
Copyright David Johnson (c) 2020
Author David Johnson
Category Web
Home page
Bug tracker
Uploaded by DavidJohnson at 2020-05-17T07:45:02Z
Distributions NixOS:
Executables exe
Downloads 310 total (1 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-05-17 [all 1 reports]

Readme for servant-wasm-

[back to package description]


Hackage Haskell Programming Language BSD3 LICENSE Build Status

Content-Type support for delivering WASM with servant


{-# LANGUAGE DataKinds         #-}
{-# LANGUAGE TypeOperators     #-}
{-# LANGUAGE TypeApplications  #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where

import           Control.Monad.IO.Class     (liftIO)
import qualified Data.ByteString            as B
import           Data.ByteString            (ByteString)
import           Data.Proxy                 (Proxy (Proxy))
import           Network.Wai.Handler.Warp   (run)
import           Servant.Server             (serve, Handler)
import           Servant.API                ((:>), Get)
import           Servant.WASM               (WASM)

type API = "wasm" :> Get '[WASM] ByteString

main :: IO ()
main = do
  putStrLn "Running on 3000..."
  run 3000 (serve (Proxy @ API) wasmHandler)

wasmHandler :: Handler ByteString
wasmHandler = liftIO (B.readFile "hello.wasm")