The remote-json package

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain]

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

Versions0.2, 0.2
Change logNone available
Dependenciesaeson (>=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]
LicenseBSD3
Copyright(c) 2016 The University of Kansas
AuthorJustin Dawson and Andy Gill
MaintainerJDawson@ku.edu
CategoryNetwork
Source repositoryhead: git clone git://github.com/ku-fpg/remote-json
UploadedTue Feb 9 20:02:28 UTC 2016 by AndyGill

Modules

[Index]

Downloads

Maintainers' 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