Some haddock docs.

Ilya V. Portnov [2010-04-23 06:52:04]
Some haddock docs.
Filename
Network/YAML/Balancer.hs
Network/YAML/Instances.hs
Network/YAML/Server.hs
diff --git a/Network/YAML/Balancer.hs b/Network/YAML/Balancer.hs
index 86d4fd0..4c05fbe 100644
--- a/Network/YAML/Balancer.hs
+++ b/Network/YAML/Balancer.hs
@@ -6,7 +6,10 @@ import qualified Data.ByteString.Char8 as BS

 type Server = (BS.ByteString, Int)

-selectRandom :: [(BS.ByteString, Server, Int)] -> BS.ByteString -> IO Server
+-- | Select random server
+selectRandom :: [(BS.ByteString, Server, Int)]   -- ^ [(Service name, (hostname, port number), priority)]
+             -> BS.ByteString                    -- ^ Service name
+             -> IO Server
 selectRandom lst service = do
   let lst' = concatMap (\(name,srv,p) -> replicate p (name, srv)) lst
       lst'' = map snd $ filter (\(name,srv) -> name==service) lst'
diff --git a/Network/YAML/Instances.hs b/Network/YAML/Instances.hs
index e774126..8a563f2 100644
--- a/Network/YAML/Instances.hs
+++ b/Network/YAML/Instances.hs
@@ -10,9 +10,11 @@ import qualified Data.ByteString.Char8 as BS

 import Network.YAML.Base

+-- | Build YamlObject from (key,value) pairs
 object :: [(BS.ByteString, YamlScalar)] -> YamlObject
 object pairs = Mapping [(toYamlScalar name, Scalar val) | (name,val) <- pairs]

+-- | Build YamlObject with single field
 field :: (IsYamlScalar a) => BS.ByteString -> a -> YamlObject
 field name val = Mapping [(toYamlScalar name, Scalar $ toYamlScalar val)]

@@ -82,6 +84,7 @@ instance Default Call where

 instance IsYamlObject Call where

+-- | Convert any (a -> IO b) action to YAML RPC method
 yamlMethod :: (IsYamlObject a, IsYamlObject b) => (a -> IO b) -> YamlObject -> IO YamlObject
 yamlMethod fn = \obj -> do
   let x = cs obj
diff --git a/Network/YAML/Server.hs b/Network/YAML/Server.hs
index 0907254..6240f0c 100644
--- a/Network/YAML/Server.hs
+++ b/Network/YAML/Server.hs
@@ -13,6 +13,7 @@ import Data.Object.Yaml
 import Network.YAML.Base
 import Network.YAML.Instances

+-- | Run each IO action in separate thread and return all results
 forkA :: [IO a] -> IO [a]
 forkA lst = do
     let n = length lst
@@ -24,7 +25,10 @@ forkA lst = do
       r <- x
       putMVar v r

-readHandle :: Handle -> [BS.ByteString] -> IO [BS.ByteString]
+-- | Read lines from Handle
+readHandle :: Handle
+           -> [BS.ByteString]       -- ^ Already read lines
+           -> IO [BS.ByteString]
 readHandle h acc = do
     line <- BS.hGetLine h
     let line' = if BS.null line
@@ -37,9 +41,10 @@ readHandle h acc = do
       then return acc
       else readHandle h (acc ++ [line'])

+-- | Start server and wait for connections
 server ::
-      Int
-   -> (YamlObject -> IO YamlObject)
+      Int                              -- ^ Port number
+   -> (YamlObject -> IO YamlObject)    -- ^ Worker
    -> IO ()
 server port callOut = do
 --        installHandler sigPIPE Ignore Nothing
ViewGit