Personal tools


From HaskellWiki

Revision as of 13:47, 10 February 2010 by GracjanPolak (Talk | contribs)

Jump to: navigation, search


1 HaXR — the Haskell XML-RPC library

HaXR is a library for writing XML-RPC client and server applications in Haskell.

HaXR consists of two packages: haxr and haxr-th. The latter package contains the Template Haskell code used for automatically deriving XML-RPC struct representations for Haskell records.

Christopher Milton came up with the HaXR name, thanks!

1.1 Documentation

1.1.1 Examples Server

This is a simple CGI-based server with only one method that takes two integers and returns their sum.

import Network.XmlRpc.Server
add :: Int -> Int -> IO Int
add x y = return (x + y)
main = cgiXmlRpcServer [("examples.add", fun add)]

Note: the argument to fun can be a function that takes any number of arguments. Client

This is a client that calls the method implemented by the server above and prints the result.

import Network.XmlRpc.Client
server = "http://localhost/~bjorn/cgi-bin/simple_server"
add :: String -> Int -> Int -> IO Int
add url = remote url "examples.add"
main = do
       let x = 4
	   y = 7
       z <- add server x y
       putStrLn (show x ++ " + " ++ show y ++ " = " ++ show z)

Note: the function returned by remote can be a function that takes any number of arguments. Heterogeneous structs

Have a look at examples/Person.hs for an example of how to use heterogeneous structs. haxr-th/examples/PersonTH.hs does the same using the Network.XmlRpc.THDeriveXmlRpcType module. XML-RPC introspection

This library supports XML-RPC introspection, both in the client and server. See examples/make-stubs.hs for an example of how to use introspection in a client. More examples

More example are available in the examples/ folder in the darcs repository.

1.1.2 API reference

Use the online copy of the API documentation.

1.1.3 Report

I have written a report (ps, pdf) on the design and implementation of Haskell XML-RPC. The report was written in January 2004, and is slowly getting out of date.

1.2 Download

1.2.1 Hackage

You can get the latest versions of the haxr and haxr-th packagesfrom Hackage.

1.2.2 Darcs repository

Use darcs to get the source from the repo at

$ darcs get

1.3 Reporting bugs, requesting features

To report bugs, request features, submit patches, or ask for help, email Gracjan Polak.

Some known problems are listed in the TODO file in the source distribution. If you need any of those fixed, let me know.

1.4 License

HaXR is distributed under a BSD-style license.

<div class="bar" />

Copyright 2003-2007 Björn Bringert. Copyright 2009-2010 Gracjan Polak.