The remote-json package

[ Tags: bsd3, library, network ] [ Propose Tags ]

JSON RPC, where you can using monads and applicative functors to bundle JSON RPC methods and notifications.

{-# LANGUAGE GADTs, OverloadedStrings, TypeOperators #-}

module Main where

import Control.Natural ((:~>), nat)
import Control.Remote.Monad.JSON
import Control.Remote.Monad.JSON.Router(transport,router,Call(..),methodNotFound)
import Data.Aeson
import Data.Text(Text)

-- Our small DSL

say :: Text -> RPC ()
say msg = notification "say" (List [String msg])

temperature :: RPC Int
temperature = method "temperature" None

-- Our remote program

main :: IO ()
main = do
  let s = weakSession network
  t <- send s $ do
    say "Hello, "
    say "World!"
    temperature
  print t

-- Simulate the JSON-RPC server

network :: SendAPI :~> IO
network = transport $ router sequence $ nat remote
  where
    remote :: Call a -> IO a
    remote (CallMethod "temperature" _)                 = return $ Number 42
    remote (CallNotification "say" (List [String msg])) = print msg
    remote _                                            = methodNotFound

[Skip to Readme]

Properties

Versions 0.2
Dependencies aeson (>=0.8 && <0.12), base (==4.*), exceptions (==0.8.*), fail, natural-transformation (>=0.3.1 && <0.4), remote-monad (==0.2), text (==1.2.*), transformers (>=0.4 && <0.6), unordered-containers (>=0.2.5 && <0.2.7), vector (==0.11.*) [details]
License BSD3
Copyright (c) 2016 The University of Kansas
Author Justin Dawson and Andy Gill
Maintainer JDawson@ku.edu
Category Network
Source repository head: git clone git://github.com/ku-fpg/remote-json
Uploaded Tue Feb 9 20:03:21 UTC 2016 by AndyGill
Distributions NixOS:0.2
Downloads 88 total (3 in the last 30 days)
Rating 0.0 (0 ratings) [clear rating]
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for remote-json-0.2

[back to package description]

remote-json Build Status

JSON RPC using the remote monad