haxr-3000.7: XML-RPC client and server library.

Portabilitynon-portable (requires extensions and non-portable libraries)
Stabilityexperimental
Maintainerbjorn@bringert.net

Network.XmlRpc.Internals

Contents

Description

This module contains the core functionality of the XML-RPC library. Most applications should not need to use this module. Client applications should use Network.XmlRpc.Client and server applications should use Network.XmlRpc.Server.

The XML-RPC specifcation is available at http://www.xmlrpc.com/spec.

Synopsis

Method calls and repsonses

data MethodCall Source

An XML-RPC method call. Consists of a method name and a list of parameters.

Constructors

MethodCall String [Value] 

data MethodResponse Source

An XML-RPC response.

Constructors

Return Value

A method response returning a value

Fault Int String

A fault response

XML-RPC types

data Value Source

An XML-RPC value.

Constructors

ValueInt Int

int or i4

ValueBool Bool

bool

ValueString String

string

ValueDouble Double

double

ValueDateTime LocalTime

dateTime.iso8601

ValueBase64 String

base 64

ValueStruct [(String, Value)]

struct

ValueArray [Value]

array

Instances

Eq Value 
Show Value 
XmlRpcType Value

Exists to allow explicit type conversions.

data Type Source

An XML-RPC value. Use for error messages and introspection.

Instances

class XmlRpcType a whereSource

A class for mapping Haskell types to XML-RPC types.

Methods

toValue :: a -> ValueSource

Convert from this type to a Value

fromValue :: Monad m => Value -> Err m aSource

Convert from a Value to this type. May fail if if there is a type error.

getType :: a -> TypeSource

Converting from XML

parseResponse :: Monad m => String -> Err m MethodResponseSource

Parses a method response from XML.

parseCall :: Monad m => String -> Err m MethodCallSource

Parses a method call from XML.

getFieldSource

Arguments

:: (Monad m, XmlRpcType a) 
=> String

Field name

-> [(String, Value)]

Struct

-> Err m a 

Get a field value from a (possibly heterogeneous) struct.

getFieldMaybeSource

Arguments

:: (Monad m, XmlRpcType a) 
=> String

Field name

-> [(String, Value)]

Struct

-> Err m (Maybe a) 

Get a field value from a (possibly heterogeneous) struct.

Converting to XML

renderCall :: MethodCall -> StringSource

Makes an XML-representation of a method call. FIXME: pretty prints ugly XML

renderResponse :: MethodResponse -> StringSource

Makes an XML-representation of a method response. FIXME: pretty prints ugly XML

Error monad

type Err m a = ErrorT String m aSource

The format for "dateTime.iso8601"

maybeToMSource

Arguments

:: Monad m 
=> String

Error message to fail with for Nothing

-> Maybe a

The Maybe value.

-> m a

The resulting value in the monad.

Convert a Maybe value to a value in any monad

handleError :: Monad m => (String -> m a) -> Err m a -> m aSource

Handle errors from the error monad.

ioErrorToErr :: IO a -> Err IO aSource

Catch IO errors in the error monad.