The yaml-rpc package

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

This library aimed to organize remote procedure call (RPC) over HTTP protocol, using YAML as data serialization format.

[Skip to Readme]


Versions 0.1, 0.2, 0.3, 0.3.1, 1.0, 1.0.1, 1.0.2, 1.0.3
Dependencies aeson (>=, base (>=3 && <=5), bytestring (>=, containers, http-client (>=, http-types (>=0.8.5), lens (>=4.2), template-haskell, text (>=, th-lift, transformers (>=, unordered-containers (>=, vector (>=, wreq, yaml [details]
License BSD3
Author Ilya V. Portnov
Category Network
Home page
Source repository head: git clone
Uploaded Sat Jun 21 17:27:46 UTC 2014 by IlyaPortnov
Distributions NixOS:1.0.3
Downloads 1475 total (12 in the last 30 days)
Rating 0.0 (0 ratings) [clear rating]
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2016-12-14 [all 8 reports]
Hackage Matrix CI


  • Network
    • Network.YAML
      • Network.YAML.API
      • Network.YAML.Caller
      • TH
        • Network.YAML.TH.Client
        • Network.YAML.TH.Dispatcher
        • Network.YAML.TH.Server


Maintainer's Corner

For package maintainers and hackage trustees

Readme for yaml-rpc-1.0

[back to package description]


Ilya V. Portnov

The yaml-rpc package contains a small library to organize remote procedure call (RPC) over TCP/IP network, using YAML as data serialization format.

RPC server should supply a set of "RPC methods", which are simply functions :: a -> b -> ... -> IO c. Arguments must be of class ToJSON (defined in aeson package); result must be of class FromJSON (defined in aeson package too). One can of cause use GHC Generics mechanism to derive needed instances. yaml-rpc package provides a (TemplateHaskell) function Network.YAML.TH.Server.makeAPI to generate API description for server. Such API can be automatically written to file in simple YAML format by using function Network.YAML.TH.Server.writeAPI. It is possible to write different servers, which will use generated API description and provide HTTP REST YAML services with that API. Currently there is only one implementation using scotty package; it is provided by yaml-rpc-scotty package. Please see yaml-rpc-scotty/Test/{Server.hs, TestAPIImpl.hs} files for example usage.

RPC client calls that functions via HTTP REST YAML interface. So, it can be used either from Haskell or from any other environment. For example, though HTTP REST YAML is nearly a superset of HTTP REST JSON, it can be easily used from JavaScript with JQuery or another framework. For Haskell, yaml-rpc package provides a function to call any method via HTTP REST YAML interface. Moreover, a (TemplateHaskell) function Network.YAML.TH.Client.useAPI function will read API description from file (in YAML format) and generate wrapper methods for calling respective remote methods. Please see Test/Client.hs for example usage.

Currently, only one-connection-per-call mode is supported by Caller module. There are plans to implement persistent connection support.

API description files can contain not only methods description, but also data types description. Types description can be also automagically generated from usual Haskell definitions and written to API description file. Then, when reading that API description file, usual Haskell data type definitions are generated.

Please see test.api file for example of API description format.

On the server side, usual workflow is as following:

  • Write some number of API data types and functions to be exposed.
  • Call makeAPI function to generate API description.
  • Call writeAPI function to write API description to file.
  • Call generateDispatcher function on generated API to generate function dispatch :: Text -> Maybe (Value -> IO Value). This function will be used by any server implementation.
  • Launch any server implementation and provide it by dispatch function.

On the client side, usual workflow is as following:

  • Receive API description file from service provider.
  • Call useAPI function on that file; it will generate data types definitions and wrapper functions to call all methods declared in file.
  • Call generated wrappers.

Depends: ghc >= 7.6, yaml, template-haskell, th-lift, wreq, lens, scotty.