-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | XML-RPC client and server library.
--   
--   HaXR is a library for writing XML-RPC client and server applications
--   in Haskell.
@package haxr
@version 3000.9.0.1


-- | This is a fast non-pretty-printer for turning the internal
--   representation of generic structured XML documents into Lazy
--   ByteStrings. Like in Text.Xml.HaXml.Pretty, there is one pp function
--   for each type in Text.Xml.HaXml.Types, so you can pretty-print as much
--   or as little of the document as you wish.
module Network.XmlRpc.Pretty

-- | Render a <a>Document</a> to a <a>ByteString</a>.
document :: Document i -> ByteString
content :: Content i -> ByteString
element :: Element i -> ByteString
doctypedecl :: DocTypeDecl -> ByteString
prolog :: Prolog -> ByteString
cp :: CP -> ByteString
instance [overlap ok] Monoid MBuilder
instance [overlap ok] IsString MBuilder


-- | This module contains the core functionality of the XML-RPC library.
--   Most applications should not need to use this module. Client
--   applications should use <a>Network.XmlRpc.Client</a> and server
--   applications should use <a>Network.XmlRpc.Server</a>.
--   
--   The XML-RPC specifcation is available at
--   <a>http://www.xmlrpc.com/spec</a>.
module Network.XmlRpc.Internals

-- | An XML-RPC method call. Consists of a method name and a list of
--   parameters.
data MethodCall
MethodCall :: String -> [Value] -> MethodCall

-- | An XML-RPC response.
data MethodResponse

-- | A method response returning a value
Return :: Value -> MethodResponse

-- | A fault response
Fault :: Int -> String -> MethodResponse

-- | An XML-RPC value.
data Value

-- | int or i4
ValueInt :: Int -> Value

-- | bool
ValueBool :: Bool -> Value

-- | string
ValueString :: String -> Value

-- | double
ValueDouble :: Double -> Value

-- | dateTime.iso8601
ValueDateTime :: LocalTime -> Value

-- | base 64. NOTE that you should provide the raw data; the haxr library
--   takes care of doing the base-64 encoding.
ValueBase64 :: ByteString -> Value

-- | struct
ValueStruct :: [(String, Value)] -> Value

-- | array
ValueArray :: [Value] -> Value

-- | An XML-RPC value. Use for error messages and introspection.
data Type
TInt :: Type
TBool :: Type
TString :: Type
TDouble :: Type
TDateTime :: Type
TBase64 :: Type
TStruct :: Type
TArray :: Type
TUnknown :: Type

-- | A class for mapping Haskell types to XML-RPC types.
class XmlRpcType a
toValue :: XmlRpcType a => a -> Value
fromValue :: (XmlRpcType a, Monad m) => Value -> Err m a
getType :: XmlRpcType a => a -> Type

-- | Parses a method response from XML.
parseResponse :: (Show e, MonadError e m) => String -> Err m MethodResponse

-- | Parses a method call from XML.
parseCall :: (Show e, MonadError e m) => String -> Err m MethodCall

-- | Get a field value from a (possibly heterogeneous) struct.
getField :: (Monad m, XmlRpcType a) => String -> [(String, Value)] -> Err m a

-- | Get a field value from a (possibly heterogeneous) struct.
getFieldMaybe :: (Monad m, XmlRpcType a) => String -> [(String, Value)] -> Err m (Maybe a)

-- | Makes an XML-representation of a method call. FIXME: pretty prints
--   ugly XML
renderCall :: MethodCall -> ByteString

-- | Makes an XML-representation of a method response. FIXME: pretty prints
--   ugly XML
renderResponse :: MethodResponse -> ByteString
type Err m a = ErrorT String m a

-- | Convert a <a>Maybe</a> value to a value in any monad
maybeToM :: Monad m => String -> Maybe a -> m a

-- | Handle errors from the error monad.
handleError :: Monad m => (String -> m a) -> Err m a -> m a

-- | Catch IO errors in the error monad.
ioErrorToErr :: IO a -> Err IO a
instance [overlap ok] Eq Value
instance [overlap ok] Show Value
instance [overlap ok] Eq MethodResponse
instance [overlap ok] Show MethodResponse
instance [overlap ok] Eq MethodCall
instance [overlap ok] Show MethodCall
instance [overlap ok] Eq Type
instance [overlap ok] (XmlRpcType a, XmlRpcType b) => XmlRpcType (a, b)
instance [overlap ok] (XmlRpcType a, XmlRpcType b, XmlRpcType c) => XmlRpcType (a, b, c)
instance [overlap ok] (XmlRpcType a, XmlRpcType b, XmlRpcType c, XmlRpcType d) => XmlRpcType (a, b, c, d)
instance [overlap ok] (XmlRpcType a, XmlRpcType b, XmlRpcType c, XmlRpcType d, XmlRpcType e) => XmlRpcType (a, b, c, d, e)
instance [overlap ok] XmlRpcType a => XmlRpcType [(String, a)]
instance [overlap ok] XmlRpcType a => XmlRpcType [a]
instance [overlap ok] XmlRpcType CalendarTime
instance [overlap ok] XmlRpcType LocalTime
instance [overlap ok] XmlRpcType Double
instance [overlap ok] XmlRpcType ByteString
instance [overlap ok] XmlRpcType String
instance [overlap ok] XmlRpcType Bool
instance [overlap ok] XmlRpcType Int
instance [overlap ok] XmlRpcType Value
instance [overlap ok] Read Type
instance [overlap ok] Show Type


-- | This module contains the server functionality of XML-RPC. The XML-RPC
--   specifcation is available at <a>http://www.xmlrpc.com/spec</a>.
--   
--   A simple CGI-based XML-RPC server application:
--   
--   <pre>
--   import Network.XmlRpc.Server 
--   
--   add :: Int -&gt; Int -&gt; IO Int
--   add x y = return (x + y)
--   
--   main = cgiXmlRpcServer [("examples.add", fun add)]
--   </pre>
module Network.XmlRpc.Server

-- | The type of XML-RPC methods on the server.
type XmlRpcMethod = (MethodCall -> ServerResult, Signature)
type ServerResult = Err IO MethodResponse

-- | Turns any function <tt>(XmlRpcType t1, ..., XmlRpcType tn, XmlRpcType
--   r) =&gt; t1 -&gt; ... -&gt; tn -&gt; IO r</tt> into an
--   <a>XmlRpcMethod</a>
fun :: XmlRpcFun a => a -> XmlRpcMethod

-- | Reads a method call from a string, uses the supplied method to
--   generate a response and returns that response as a string
handleCall :: (MethodCall -> ServerResult) -> String -> IO ByteString

-- | An XmlRpcMethod that looks up the method name in a table and uses that
--   method to handle the call.
methods :: [(String, XmlRpcMethod)] -> MethodCall -> ServerResult

-- | A CGI-based XML-RPC server. Reads a request from standard input and
--   writes some HTTP headers (Content-Type and Content-Length), followed
--   by the response to standard output. Supports introspection.
cgiXmlRpcServer :: [(String, XmlRpcMethod)] -> IO ()
instance [overlap ok] (XmlRpcType a, XmlRpcFun b) => XmlRpcFun (a -> b)
instance [overlap ok] XmlRpcType a => XmlRpcFun (IO a)


-- | Uses Template Haskell to automagically derive instances of
--   <a>XmlRpcType</a>
module Network.XmlRpc.THDeriveXmlRpcType

-- | Creates an <a>XmlRpcType</a> instance which handles a Haskell record
--   as an XmlRpc struct. Example: <tt> data Person = Person { name ::
--   String, age :: Int } $(asXmlRpcStruct ''Person) </tt>
asXmlRpcStruct :: Name -> Q [Dec]


-- | This module contains the client functionality of XML-RPC. The XML-RPC
--   specifcation is available at <a>http://www.xmlrpc.com/spec</a>.
--   
--   A simple client application:
--   
--   <pre>
--   import Network.XmlRpc.Client
--   
--   server = "http://localhost/~bjorn/cgi-bin/simple_server"
--   
--   add :: String -&gt; Int -&gt; Int -&gt; IO Int
--   add url = remote url "examples.add"
--   
--   main = do
--          let x = 4
--              y = 7
--          z &lt;- add server x y
--          putStrLn (show x ++ " + " ++ show y ++ " = " ++ show z)
--   </pre>
module Network.XmlRpc.Client

-- | Call a remote method.
remote :: Remote a => String -> String -> a

-- | Low-level method calling function. Use this function if you need to do
--   custom conversions between XML-RPC types and Haskell types. Throws an
--   exception if the response was a fault.
call :: String -> String -> [Value] -> Err IO Value
class Remote a
instance [overlap ok] (XmlRpcType a, Remote b) => Remote (a -> b)
instance [overlap ok] XmlRpcType a => Remote (IO a)

module Network.XmlRpc.Introspect
type Signature = ([Type], Type)
type Help = String
type MethodInfo = (String, [Signature], Help)
listMethods :: String -> IO [String]
methodSignature :: String -> String -> IO [[String]]
methodHelp :: String -> String -> IO String
signatures :: String -> String -> IO [Signature]
methodInfo :: String -> String -> IO MethodInfo
