Skip to content

SX91/haskell-msgpackrpc

Repository files navigation

Build Status

haskell-msgpackrpc

MsgPack RPC implementation for Haskell (server side only, for now)

Example

{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
import           BasicPrelude              hiding (catch, finally, try)

import           Control.Monad.Catch
import qualified Data.Map                  as Map

import           Network.MsgpackRpc.Server


default (Text)

-- This sums arguments
sumMethod :: Int -> Int -> RpcMethodT IO Int
sumMethod a b = return $! a + b

-- This throws error to client
errorMethod :: RpcMethodT IO Int
errorMethod = throwM $ rpcError ".MyRpc.SomeCoolError" ("WAT!?" :: Text)

func :: IO ()
func = do
    let methodMap =  Map.fromList
            [
              ("sum", rpcMethod sumMethod)
            , ("error", rpcMethod errorMethod)
            ]
    serveRpc 128 (serverSettings 5252 "*") methodMap

main :: IO ()
main = func

About

MessagePack RPC for Haskell

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published