MyNixOS website logo
Description

a remote procedure call framework.

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

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

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 sendpure functions across the wire and now garbage collect them.
    instance (Serializable a) => Sendable a a
    instance (Sendable a' a, Sendable b b') => Sendable (a -> b) (a' -> IO 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.
Metadata

Version

2.0.0.2

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows