The rpc-framework package

[Tags:bsd3, library, program]

A library and framework for making remote procedure calls in haskell easy and typesafe.

See http://github.com/mmirman/rpc-framework for more information.


[Skip to Readme]

Properties

Versions 0.0.0.0, 0.0.0.1, 0.1.0.0, 0.2.0.0, 0.3.0.0, 1.0.0.0, 2.0.0.0, 2.0.0.1, 2.0.0.2
Dependencies base (>=4.3 && <5.0), containers (>=0.4 && <0.6), mtl (>=2.0 && <2.2), network (>=2.0 && <2.5), rpc-framework, template-haskell (==2.7.*), transformers (>=0.2 && <0.4) [details]
License BSD3
Author Matthew Mirman
Maintainer mmirman@andrew.cmu.edu
Stability Unknown
Category Network, Web
Home page http://github.com/mmirman/rpc-framework
Source repository head: git clone git://github.com/mmirman/rpc-framework.git
Uploaded Wed Jul 25 21:35:34 UTC 2012 by MatthewMirman
Distributions NixOS:2.0.0.2
Downloads 1649 total (25 in the last 30 days)
Votes
1 []
Status Docs uploaded by user
Build status unknown [no reports yet]

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for rpc-framework

Readme for rpc-framework-0.0.0.1

rpc-framework

This is a framework for remote procedure calls in haskell.

Features

  • Usage is incredibly simple!

  • Calling a remote procedure is type safe.

  • Modal logic inspired worlds, aka hosts:

    • Services run from the World IO monad, written Host w => WIO w
    • This allows world specific actions: if one world will be compiled to JS and one to x86, we could have the following types
    putStrLn :: IO_World w => WIO w a
    installTextBox :: JS_World w => WIO w ()
  • Arbitrily complex remote procedures:
    • Rather than only being able to call a remote function of one argument, we can call with any number of arguments
    foo :: (Sendable a1 ,..., Sendable aN, Sendable b, Host w) => a1 -> ... -> aN -> WIO w b
  • It can send pure functions across the wire note this really sets up a service and the sent function will persist indefinitely, and thus is slow. This also means that the function received isn't really pure
    instance (Serializable a) => Sendable a
    instance (Sendable a, Sendable b) => Sendable (a -> b)
  • Only local code can execute

    • unlike some modal logic aproaches to mobile languages, the only code that can be executed is the code you compiled, and not code passed from world to world
  • State can be serialized with references.

Usage

  • To install, run cabal install

  • Hosts are declared at the declaration level

    $(makeHost "WorldName" "host_location" #portNumber)
  • Installing a remote service:
    • makeServices registers a list of service names which all have the same host
    • autoService automatically figures out which services in the given file run on the specified host and registers them. A good usage pattern is to provide all modules with services with a registration hook that can be appended to the main server.
    main = runServer $(makeServices [ 'nameOfService1, ... , 'nameOfServiceN])
    main = runServer $(autoService 'HostName)
    module First where
    services = $(autoService 'HostName)

    module Second where
    services = $(autoService 'HostName)

    module Main where
    import qualified First as F
    import qualified Second as S
    main = runServer $ F.services >> S.services
  • Calling a remote service:
    addServer :: Integer -> WIO Server (Integer -> Integer)
    addServer t = do
        Server <- world
    return (t +)

    getRemoteAdd = $(rpcCall 'addServer)
    ...
    ghci> :t getRemoteAdd
    getRemoteAdd  :: Host w => Integer -> WIO w (Integer -> Integer)

Examples

  • src/RPCTest.hs is an example.
    • It runs two worlds, Client and Server, both on localhost, one on port 9000 and the other on 9001.
    • To run and build it: make run
    • To build it: make test
    • To run it after building it: ./rpc-test