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

Copyright(c) Bjorn Bringert 2003
LicenseBSD-style
Maintainerbjorn@bringert.net
Stabilityexperimental
Portabilitynon-portable (requires extensions and non-portable libraries)
Safe HaskellNone
LanguageHaskell2010

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 #

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

Constructors

MethodCall String [Value] 

data MethodResponse #

An XML-RPC response.

Constructors

Return Value

A method response returning a value

Fault Int String

A fault response

XML-RPC types

data Value #

An XML-RPC value.

Constructors

ValueInt Int

int, i4, or i8

ValueBool Bool

bool

ValueString String

string

ValueUnwrapped String

no inner element

ValueDouble Double

double

ValueDateTime LocalTime

dateTime.iso8601

ValueBase64 ByteString

base 64. NOTE that you should provide the raw data; the haxr library takes care of doing the base-64 encoding.

ValueStruct [(String, Value)]

struct

ValueArray [Value]

array

Instances

Eq Value # 

Methods

(==) :: Value -> Value -> Bool #

(/=) :: Value -> Value -> Bool #

Show Value # 

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

XmlRpcType Value #

Exists to allow explicit type conversions.

Methods

toValue :: Value -> Value #

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

getType :: Value -> Type #

data Type #

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

Instances

class XmlRpcType a where #

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

Minimal complete definition

toValue, fromValue, getType

Methods

toValue :: a -> Value #

Convert from this type to a Value

fromValue :: Monad m => Value -> Err m a #

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

getType :: a -> Type #

Instances

XmlRpcType Bool # 

Methods

toValue :: Bool -> Value #

fromValue :: Monad m => Value -> Err m Bool #

getType :: Bool -> Type #

XmlRpcType Double # 
XmlRpcType Int # 

Methods

toValue :: Int -> Value #

fromValue :: Monad m => Value -> Err m Int #

getType :: Int -> Type #

XmlRpcType ByteString # 
XmlRpcType String # 
XmlRpcType Text # 

Methods

toValue :: Text -> Value #

fromValue :: Monad m => Value -> Err m Text #

getType :: Text -> Type #

XmlRpcType CalendarTime # 
XmlRpcType LocalTime # 
XmlRpcType Value #

Exists to allow explicit type conversions.

Methods

toValue :: Value -> Value #

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

getType :: Value -> Type #

XmlRpcType a => XmlRpcType [(String, a)] # 

Methods

toValue :: [(String, a)] -> Value #

fromValue :: Monad m => Value -> Err m [(String, a)] #

getType :: [(String, a)] -> Type #

XmlRpcType a => XmlRpcType [a] # 

Methods

toValue :: [a] -> Value #

fromValue :: Monad m => Value -> Err m [a] #

getType :: [a] -> Type #

(XmlRpcType a, XmlRpcType b) => XmlRpcType (a, b) # 

Methods

toValue :: (a, b) -> Value #

fromValue :: Monad m => Value -> Err m (a, b) #

getType :: (a, b) -> Type #

(XmlRpcType a, XmlRpcType b, XmlRpcType c) => XmlRpcType (a, b, c) # 

Methods

toValue :: (a, b, c) -> Value #

fromValue :: Monad m => Value -> Err m (a, b, c) #

getType :: (a, b, c) -> Type #

(XmlRpcType a, XmlRpcType b, XmlRpcType c, XmlRpcType d) => XmlRpcType (a, b, c, d) # 

Methods

toValue :: (a, b, c, d) -> Value #

fromValue :: Monad m => Value -> Err m (a, b, c, d) #

getType :: (a, b, c, d) -> Type #

(XmlRpcType a, XmlRpcType b, XmlRpcType c, XmlRpcType d, XmlRpcType e) => XmlRpcType (a, b, c, d, e) # 

Methods

toValue :: (a, b, c, d, e) -> Value #

fromValue :: Monad m => Value -> Err m (a, b, c, d, e) #

getType :: (a, b, c, d, e) -> Type #

Converting from XML

parseResponse :: (Show e, MonadError e m) => String -> Err m MethodResponse #

Parses a method response from XML.

parseCall :: (Show e, MonadError e m) => String -> Err m MethodCall #

Parses a method call from XML.

getField #

Arguments

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

Field name

-> [(String, Value)]

Struct

-> Err m a 

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

getFieldMaybe #

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 -> ByteString #

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

renderResponse :: MethodResponse -> ByteString #

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

Converting to and from DTD types

Error monad

type Err m a = ExceptT String m a #

maybeToM #

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 a #

Handle errors from the error monad.

ioErrorToErr :: IO a -> Err IO a #

Catch IO errors in the error monad.