Popularity
1.9
Declining
Activity
0.0
Stable
4
2
0

Monthly Downloads: 7
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Tags: Web     Servant    
Latest version: v0.1.0.0

servant-wasm alternatives and similar packages

Based on the "servant" category.
Alternatively, view servant-wasm alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of servant-wasm or a related project?

Add another 'servant' Package

README

servant-wasm

Hackage Haskell Programming Language BSD3 LICENSE Build Status

Content-Type support for delivering WASM with servant

Usage

{-# 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")

and corresponding JS to fetch WASM client-side.

const importObject = {};
WebAssembly.instantiateStreaming(fetch('/wasm'), importObject).then(results => {
  // Do something with the results!
});


*Note that all licence references and agreements mentioned in the servant-wasm README section above are relevant to that project's source code only.